Questions tagged [after-trigger]

After triggers are used to access field values that are set by the system (such as a record's Id or LastModifiedDate field), and to affect changes in other records.

Filter by
Sorted by
Tagged with
-1
votes
1answer
20 views

ERROR: 'Variable does not exist

I have a trigger bellow which calculates a sum of field in a related field in custom object . I am getting an error massage Variable does not exist:House_Improvements__c. Any ideas how can I resolve ...
0
votes
0answers
27 views

Trigger does not update prepopulated field value [closed]

There is discount field on the Quote Pricing object. And the Quote pricing object has Quote lookup on it. i.e Quote can have multiple Quote pricing records. When the Quote pricing object record gets ...
2
votes
1answer
68 views

Do trigger.newMap and trigger.oldMap have the same keySet() in apex after update triggers?

My potential use case by knowing the answer to this question would be, if I'm working with a legacy code and I can't make modification to the method signature and I only have access to trigger.new and ...
0
votes
0answers
13 views

Populate Contact Custom Picklist Filed Value in Account's Custom FIeld

I've Created a custom picklist field on Contact 'Contact_Rating__c' with the values High, Medium, Low and created 2 fields on Account 'ContactHighestRating__c , ContactNameWithHighestRating__c' if ...
1
vote
2answers
165 views

Is my after insert trigger efficient and safe to port to production?

Recently I created an after insert trigger to update a field in my sponsorship object. it works so far in sandbox and has passed the unit test that I have created and has 100% code coverage. here is ...
1
vote
1answer
19 views

pass list of sObject from one queueable job to another

I am trying to pass Sobject from trigger to a queueable and then i am calling another queueable and trying to pass the same sObject. But i am unable to get the values in queueable . Trigger - ...
1
vote
1answer
15 views

Is it possible to access the Lead ID on a newly created Campaign Member through the Trigger?

I'm writing a trigger on Campaign members, and I'd like to use the ID of the Lead associated with the campaign member. When I try to access the Lead Id in the trigger it returns null. Is it possible ...
1
vote
1answer
29 views

Test Class for Trigger After Delete with Update Opportunity

I'm writing a very simple trigger. At this point I have 100% coverage, but I don't feel like the tests are robust enough. High Level Opportunity Contact Role Trigger that fires on Delete. The ...
0
votes
1answer
58 views

Bulkify a Trigger

I have written a trigger on Tenant_Details__c object which has a lookup relationship to Room_Details__c object. Every time a new record is inserted, I want to update a field in Room_Details__c and ...
0
votes
2answers
23 views

maximum trigger depth exceeded while updating old child records

I tried to check previous answers here for similar issue but I could not apply it in my condition We have a scenario where Account is master and Annual Potential is a child object, THe scenario is ...
1
vote
2answers
47 views

Apex Trigger Order of Execution Transaction

I am a bit confused lately regarding the order of execution of multiple updates: Consider the following scenario: I have Three Records: A and B and C A fires an after update trigger that updates ...
0
votes
0answers
22 views

Task Creation when case is created [duplicate]

I am getting below error. Error: Invalid Data. Review all error messages below to correct your data. Apex trigger CaseTaskCreationTrigger caused an unexpected exception, contact your ...
0
votes
1answer
45 views

How to make two callouts in sync?

From Trigger on inserting I am making a callout (from method1 of class A) i.e by using @future annotation and updating the field of the same object on which the trigger called, with the values ...
1
vote
1answer
75 views

How to force future method to wait until current thread finish?

I have an apex code which is called from an after trigger. The apex code calls a future method and sometimes the future method runs after the execution of the current thread and sometimes does not. I ...
0
votes
1answer
34 views

Testing Apex Trigger with Asynchronous HTTP Callouts

I have an apex trigger f_contactPushNotificationTrigger that should fire when a new contact is created. This trigger call f_PushNotification class used to Post data. I used @future to make this task ...
-1
votes
1answer
46 views

Variable does not exist:Trigger

I'm getting a Variable does not exist:Trigger error on this trigger. What am I doing wrong in the code? Please assist trigger calcClaim on Claim__c (after Insert, after Update, Before Delete){ set<...
0
votes
0answers
31 views

Trigger Error on Bulk Upload

I am trying to upload bulk Contact records into salesforce through import wizard for code quality check. While doing so i found the following error. CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:Too many ...
0
votes
1answer
24 views

CreatedBy.Name returns null in after insert trigger context

I got an after insert trigger that runs on the Task object, can someone explain why I'm getting null when trying to retrieve the createdBy.Name? for (Task t: (List < Task > ) Trigger.New) { ...
0
votes
1answer
22 views

Campaign Member Trigger to reference related Lead level field values [duplicate]

I am trying to write values to the Campaign Member fields based on values from the related Lead record. When I attempt to run this I get the error message: addCampaignMemberValues: execution of ...
0
votes
1answer
76 views

Apex - Approval Process - getting INVALID_CROSS_REFERENCE_KEY when calling Approval.process()

The class below has a method that runs on an After Update Trigger for a custom object. It attempts to automatically Reject the approval process when a picklist field (Work_Sub_Status__c) on its Target ...
1
vote
2answers
48 views

SOQL Query Exception Non Selective Query in after insert Trigger

I am loading contacts records and when my after insert triggers runs I am getting the following error: System.QueryException: Non-selective query against large object type (more than 200000 rows)...
1
vote
1answer
60 views

Trigger to update all children not giving expected results

I'm replacing a formula field (due to hitting the max number of 15 object references) with a trigger on Account (after insert/update) and on Contact (before insert/update). There are three account ...
0
votes
1answer
31 views

After Insert trigger behaviour if insertion execution fails

I have a custom object named 'shift_cancellation__c'. This custom object records are being populated by parsing an email. I have a class named 'shiftCancellationListener' that parses the emails and ...
-2
votes
2answers
38 views

Trigger to update Account on updating contact

Can someone please tell why below sample code is not working Trigger UpdateParent on contact (After Update){ List<Account> acc = new List<Account>(); for(Contact c : Trigger....
0
votes
1answer
28 views

trigger throwing error on bulk insert for opportunity object

I worked on one trigger which will update the related account and contacts related to that account on insert or update. but on inserting bulk opportunities for single account then I am getting below ...
0
votes
1answer
29 views

Exception in trigger, fail to update the field on account which is used to count the number of contact with specific type

Please help me out. I posted my trigger please it throws the exception Exception Details: Update failed. First exception on row 0 with id 0035000003IGI8AAAX; first error: ...
1
vote
2answers
68 views

Before/After Trigger

Question When a Billing Address is modified, get the new Postal Code. Then check which Contacts on the Account are outside that Postal Code. If 1 or more Contacts are outside of the Postal Code, mark ...
0
votes
1answer
65 views

Trigger fires multiple times recursively

I have a trigger with a trigger handler class on Opportunity. I am writing a batch class to update the stage in Opportunity which should call the trigger to create a record in "Order" object. In the ...
0
votes
0answers
37 views

Apex Trigger Error

Here is my Apex Class: public class NavProductHelperClass { public void checkProductAvailability(list<OpportunityLineItem> opids) { for(OpportunityLineItem oli: opids) { ...
1
vote
1answer
74 views

Debugging Apex Triggers

I am attempting the Apex Superbadge trigger and have bugs in my code. In the past, I have only written Apex controllers attached to a LWC. So, when I open a page/use the LWC, I can then see my debug ...
1
vote
1answer
49 views

To achieve same functionality as that of account teams in custom object

I want to achieve the same functionality as that of account team in project(Custom object)  using trigger . For this I have made a new custom object as projectteam and added lookup of user as well as ...
0
votes
1answer
30 views

Parent or Child record fires BeforeUpdate trigger first when attached in Lookup Relationship?

Writing a trigger to handle updating a few fields on a record (of the same object, this is an Account to an Account lookup) when it is attached via a lookup relationship (ie. it is the parent or ...
0
votes
1answer
33 views

Apex extracting fields from a trigger to create a custom JSON

I have created a trigger for Order Object and only want specific fields to be pulled from that object to create a custom JSON data structure. I have tried saving the fields that I need from the object ...
2
votes
0answers
46 views

Problem with trigger time executions

I have 2 triggers after insert wich call one apex class each one. One of them call an apex class for make a query to get an Id from the first trigger execution. I need this ID to match two differents ...
0
votes
1answer
91 views

Test Case - Attempt to de-reference a null object (Formula Field)

Now I have 0% coverage. System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CaseHandlerCountAlert: execution of AfterInsert caused by:...
3
votes
1answer
77 views

How do I avoid a Duplicate-value during update in Trigger?

I'm changing the Clients__c value in Mopping__c if the StartDate__c, Status__c or Opportunity__c have changed in the needed Rent__c. Structure: if Mopping 1 is related to Rent 1 which is related to ...
0
votes
1answer
25 views

Trigger code error

I am really new to triggers and not sure how I fix this error, please help. Thank You, Lorr
0
votes
3answers
78 views

Update map.values() doesn't work

I don't know why my object's field from map doesn't change. Can you help me please? public void changeCommentAfterUpdate(List<OppDesc__c> newOppDesc){ Map<Id, Tool__c> mapToConnect = ...
0
votes
1answer
24 views

Trigger on Account to create case when account customfield is of type Multiselect picklist is updated

I'm having plan__c field on account object.whenever its is updated I want the new values of plan__c is the subject of a case and new case to be created if new values and old values match no case is ...
1
vote
1answer
184 views

ContentDocumentLink fires trigger multiple times on list insertion [duplicate]

We have a trigger on Order attachment insertion, so that a field is populated with a link to the attached documents whenever a user uploads one or multiple files to an existing Order. We created the ...
0
votes
0answers
19 views

CPQ-Custom field blank value email template after submit for approval on Quote

On CPQ Quote: I am a newbie to salesforce and CPQ. When quote is Submitted for approval, email templated is triggered named quote submitted for approval from CPQ package.In that email template custom ...
0
votes
1answer
37 views

Trigger after update: System.FinalException: Record is read-only [duplicate]

I have a trigger: if(Trigger.isAfter && Trigger.isUpdate) { for(SomeRecord__c newRecord : Trigger.new){ if(Trigger.oldMap.get(newRecord.Id).Worker__c != newRecord....
0
votes
2answers
51 views

What's the difference in value of Trigger context variables new and old? [closed]

I have a confusion please can anyone solve it. I know it is silly but I am new to Salesforce so I need help. In before update and after update what will be the difference between the values of ...
0
votes
2answers
209 views

How to copy LinkedEntityId/Opportuntiy id in Content version object via Apex trigger

I have created a custom field(lookup field to opportunity) on Content version object that would denote the opportunity id that file is connected to. The custom field is Opportunity__c. Here is the ...
0
votes
0answers
27 views

How to Write Trigger When User Role change Remove Permission Set For That User [duplicate]

// AFTER DELETE public static void deletePermisionAfterUpdate(List<User> lstUsers ,Map<Id,User> mapOldUsers){ List<PermissionSetAssignment> deletePermissionSets = new List<...
-3
votes
1answer
72 views

when field on child object is updated to have a value, change field on parent to be null trigger

working on this trigger for 2 custom objects in a master-detail relationship, rep is the parent, role history is the child. the insert part works perfectly, just am struggling with the update portion. ...
0
votes
2answers
33 views

if field is updated to no longer be null, change different field

working on this trigger for 2 custom objects in a master detail relationship. the insert part works perfectly, just am struggling with the update portion. i've included the entire code in case my ...
0
votes
2answers
120 views

How to query Parent object of Master-detail relationship in trigger?

So I just realized that parent fields are not available on child triggers without querying. But i've tried several different methods and do no get the expected response. I want to create a campaign ...
1
vote
1answer
52 views

After Update Trigger and wrong values

I have a Trigger and Trigger Helper. Opportunity is a parent for CompanyOrder__c. One Opportunity can have many CompanyOrder__c records with uncrossed Start- and End Dates. CompanyOrder__c is a ...
-2
votes
1answer
72 views

Run Update Trigger only if a few fields are changed [closed]

I have Trigger and Trigger Helper. My trigger looks like that: if(Trigger.isAfter && Trigger.isUpdate) { TriggerHelper.updateTools(Trigger.old, Trigger.new); TriggerHelper....

1
2 3 4 5