Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Make your voice heard. Take the 2019 Developer Survey now

Questions tagged [trigger]

A trigger is a feature of the Salesforce platform consisting of Apex code that executes before or after DML operations.

0
votes
1answer
33 views

What is the best way to schedule calls to external services?

I have a task at hand that I am trying to figure out the best way to get done. In short I need to hit an external API, GotoWebinar to be exact. I need to retrieve a list of Webinar Sessions daily ...
0
votes
1answer
33 views

Copying Standard Object information and line items to custom object with a trigger [closed]

I am creating a custom invoicing tool. When an Order or Opportunity is closed then an Invoice (invoice__c) is automatically populated with the line items copied to the invoice line items custom ...
1
vote
1answer
30 views

Are trigger limits applied for every flow

I'm checking an integration to a SF org and it seems to be hitting "Apex CPU time limit exceeded" and it is brining up different sources. Sometimes it breaks during a process builder action from a ...
0
votes
1answer
27 views

After update trigger fires twice, first with no updated info, second with info

I'm writing a trigger that chops up a long-text field on an event activity record and puts it into the appropriate fields on the related contact's record. The problem is, the code seems to be firing ...
0
votes
1answer
26 views

I'm giving access to the children of parents of a newly created account, but i think its not working, or else how to check if this is working

public class ManuallyShareAccount { public static void manualShare(List<Account> newList) { Set<Id> accSet= new Set<Id>(); for(Account acc:[SELECT ParentId ...
2
votes
0answers
80 views

Delete __Sharing object

I'm receiving the following error: TR09_MasterServiceAgreement: execution of AfterInsert caused by: System.DmlException: Delete failed. First exception on row 0 with id 02c1800002Lir2PAAR; ...
0
votes
1answer
24 views

How to catch update exception and what kind of notification to do here?

I have a trigger with helper class and test. But I don't know how to test update there and what kind of notification I need. Thanks for any help. Trigger: trigger ArchivedTrigger on Item__c (after ...
0
votes
1answer
34 views

Ignore validation on before update/insert trigger?

I have a before insert/update validation trigger which I would like to be able to ignore when doing mass updates via data loader. Figured if I just add criteria of "checkbox field = true, ignore ...
0
votes
0answers
14 views

Prefill data into FeedItem body

I have a problem, and i dont know how to make it. I need to put data into FeedItem on Case which is sent as Type TextPost. It needs to show first name and last name of the account person which is ...
0
votes
1answer
33 views

How to create OrderItem using trigger

How to create same orderItem(some field are modified) when I create any OrderItem record related to order using trigger?
1
vote
1answer
30 views

I want to create a validation rule which will throw an error if account created date is less than 6 months and type='Active'

i have used below validation rule ,but the issue is, it will check exact 180 days.there might be chances that there are 31 days in month and then days will be more than 180 days.Please suggest how can ...
0
votes
0answers
51 views

Schedule apex class to run every day

I want to make some rollups on a custom objects via a scheduled Apex class. I managed to test the rollup via an Apex trigger, which fired whenever I edited the custom object. Now I want to run it ...
0
votes
2answers
36 views

I have created a apex trigger. What is response code salesforce expecting from my endpoint in case of failure? [closed]

We are returning 200 for success but what should I return for failure?
0
votes
1answer
53 views

Create more than 50000 records with a press of a button in custom object depending on criteria

I am trying to create more than 50000 records with a press of a button inside salesforce for a full month. The records needs to be displayed with a timestamp of 5 minutes apart. Something like this: ...
0
votes
1answer
47 views

Checkbox on Account object needs to be updated when checkbox on all of its contact is checked [closed]

I have a requirement where checkbox on Account object needs to be updated when checkbox on all of its contact is checked. Suppose that account has a checkbox 'Default__c'. This account is having 3 ...
2
votes
0answers
49 views

HtmlBody of on EmailMessage does not stay as set in before insert trigger

I'm trying to cut off email threading from EmailMessage. I try to do this in BEFORE INSERT trigger. Original email: Hello Tom, We saw your complaint. We are working on it. Gigasoft ...
0
votes
2answers
35 views

Trigger not assigning a value as expected

I have a Student object that has a look up relationship to a Coach object. When a student is created, I need to assign a coach to that student, based on which coach has the least amount of students. ...
5
votes
1answer
221 views

Is it possible to access the email of a Lead's owner directly?

For instance, I am writing some code to send an email using a after insert trigger. I am wanting to get the email address of the lead owner I am currently iterating over, but am running into an error. ...
-3
votes
1answer
47 views

Getting error when saving Trigger [closed]

I'm new to salesforce. I'm trying to make the changes in developer console. We have a requirement to add PDF from external source to Sales Force Community. trigger WriteAttachmentIDToEmissionTest ...
-2
votes
1answer
37 views

Trigger to update other checkboxes if one is checked [closed]

Our companies Salesforce is connected to another system, which pushes updates to Salesforce, when the information is updated there. Is there a way to create a trigger, that updates other checkboxes, ...
0
votes
2answers
22 views

execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object in trigger

iam trying to insert the data from dataloader getting error as nullpointerexception in line29 column1. trigger emailmatchdatacontact on ContactRelationship__c (before insert,before update) { ...
0
votes
1answer
43 views

Too Many SOQL queries: 101 Exception

trigger SoM_RequestCancelledOnFeePayment on SoM_Request__c (after update) { if (!SoM_Utilities.gs.Disable_Triggers__c) { List<MUSW__Fee_Payment__c> feePymtsToUpdate = new List<...
0
votes
1answer
21 views

Check a checkbox in parent when the field of child is true

I have a field in Opportunity material which is a related list in opportunity object.That field in opportunity material is a formula field that return value true or false. I need to check a checkbox ...
0
votes
2answers
31 views

Can i refire the trigger

I have a future callout method(calls external server) in a trigger. I am calling external server in future callout method and passing data(Trigger.new) to it. If the external server is down. Is there ...
1
vote
1answer
30 views

Can the Process builder, count the number of instances and then execute a certain task

Process automator can be used to automate a lot of things within salesforce. For one such scenario can I use it to count the number of instances of a certain object and then set a checkbox value to ...
-3
votes
1answer
34 views

Trigger not working as expected

I'm new to triggers I create a trigger to update lookup field on a custom object but when I use it with a bulk update, insert the records missed up in the list, Kindly find the trigger below and help ...
2
votes
2answers
490 views

FOR Loop NOT being executed w/ NO errors

The trigger is firing, there are no errors, and it is running through all of the code, except the FOR loop w/ the SOQL query. THE QUESTION Why is the trigger not jumping into the FOR loop? THE ...
6
votes
2answers
68 views

Revoke access to delete a specific Account record type

I have this apex trigger that revokes access to users from deleting all Accounts. I was wondering how to improve it to ignore or allow certain record type. The use case is, I want to allow users to ...
0
votes
1answer
29 views

Trigger in working as expected in inline editing , But it is not not working when I click the edit button

Hi Folks I have a requirement to copy the case contact id to the task (WhoId) Field. Logic I implemented. 1: Check the task whatID is not blank and the whatId starts with 500 (Case Prefix Which ...
2
votes
2answers
69 views

Map / Trigger / Governor limits

While studying for my Platform Developer 1 exam, I came across this line. Could someone please explain how this is the case? Question: How can a developer avoid exceeding governor limits when using ...
1
vote
2answers
157 views

How prevent deletion in Event delete trigger and update a field instead

Our Salesforce users are deleting Events from Salesforce due to our integration with Outlook. When a Meeting from Outlook is deleted, we want the corresponding Event record in Salesforce to be not ...
2
votes
1answer
46 views

SOQL in Apex trigger returns [Name Set by Trigger]

Have 2 managed packages. One package contains Recurring object. Another package contains Receipt object. Opportunity has lookup fields to Recurring object and to Receipt. Created text field '...
1
vote
1answer
29 views

Trying to add child record fields into a single field in Parent object using trigger but getting an error? [duplicate]

I have two objects. Child Object: Service_Item__c and Parent Object: Case, with master detail relationship. so when a record is inserted or updated I want to add Service_Id__c and ...
-2
votes
1answer
22 views

when i test my trigger the error will shows Given below

Everyone When I test my trigger class the error will shows Given below System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are ...
0
votes
1answer
37 views

Trigger to throw an error for community users when clicked on few stages in opportunity path-how? [closed]

-------Trigger----------- trigger stageNames on Opportunity (before insert) { if (Trigger.isBefore && Trigger.isInsert) { //List<String> stageNames = new List<...
0
votes
1answer
36 views

Recieving the following error while trying to comment out Apex Trigger: “Error: Compile Error: Unexpected token '<EOF>'. at line 65 column 1 ”

I'm a point and click admin with little Apex experience in need of some assitance. I am attempting to Comment out and Apex Class in my Organization, however when attempting to update the Trigger in ...
-1
votes
0answers
31 views

Are before / after insert triggers really fired again after workflow rules? [duplicate]

According to the documentation when it comes to the order of execution and recursive trigger calls: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/...
0
votes
1answer
48 views

How to retrieve the immediate pending approver from approval process in before update trigger

I have an approval process with multiple steps. Each step updates the Employee_Bonus record. I have created a trigger on this object to capture the next pending approver using the stepsAndWorkItems. ...
0
votes
1answer
131 views

Updating parent record based on child record

I have a trigger on release(Child of Opportunity) record. Logic for trigger is in handler class. I am updating checkbox to true on Opportunity(Parent) whenever release record edited or inserted. if ...
1
vote
1answer
19 views

Trigger on ListEmail or Children records?

I'm trying to run some custom code when a list email is sent but I'm noticing the after insert trigger I have on Task does not run. I'm also unable to create a trigger on the ListEmail object. Has ...
-1
votes
1answer
26 views

how can we compare and update the records in salesforce

i have two objects that contain email fields and i have to compare two objects of records emailids if it matches email address update another field in contact by using of salesforce trigger. ...
0
votes
2answers
21 views

Incorrect results on NULL value

My trigger is very simple and but behavior of NULL condition check produce opposite results. The test data doesn't have a value for Parent_company_ID__c. Debug log also gives NULL as the ...
0
votes
1answer
18 views

Divide OpportunityLineItem Quantity Schedule Evenly

I have a requirement where we need to insert OLIQuantity Schedule automatically. I need to divide the quantity evenly to the duration given. Like if Duration = 3 and productQuantity = 11, i need to ...
0
votes
1answer
28 views

Updating records when related record is inserted

I have written at shipment insertion to update the shipment's expedited checkbox to be true, and then in the after trigger, it should update all the packages that have the newly created shipment to ...
4
votes
3answers
585 views

Confused by CalloutException

I have a trigger on Account and Opportunity - both do a callout to the Google Geocoding API and then update itself using a future method. Now I also want to send an email before the update if certain ...
0
votes
1answer
19 views

APEX Map <String,Custom Object> GetKey Issues on trigger

I am building a trigger to update ownership of Leads however while creating my map using String, Custom Object for somereason that I am unsure of is not finding the Key. When using the debuger logs I ...
0
votes
1answer
18 views

Apex code mail is not sending

i have tried out with the following code - am getting an exception of daily allowance of mail send,but actually none of the mails are send.whats the issue in this code?? public static void ...
0
votes
1answer
48 views

CPU Limit error in trigger handler class

I have a method in trigger handler class but method is taking more CPU time and sometime give CPU time error. I have to set the the AMM_OPP_Check__c to true based on related record when all the ...
1
vote
1answer
76 views

Test Class for Trigger before insert before update

I am very new to APEX and I have written the following trigger that updates the due date on a case based upon an SLA value stored in another object once the user fills a value in a lookup field ...
1
vote
1answer
19 views

How to redirect to a custom VFP after a Custom Object record is created (Standard way of insert)?

well, pretty much as the title says. I need the user to be redirected to a Custom VFP when a new record of a Custom Object is created, additional to this I need to be able to send the Id to that ...