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
0
votes
0answers
39 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
41 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
57 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
27 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
35 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
24 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
28 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
60 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
59 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
49 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
33 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
31 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 ...
1
vote
0answers
44 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
78 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
73 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
75 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
73 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
17 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
35 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
36 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
101 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
65 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
31 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
99 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
56 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
votes
1answer
51 views

AgentWork Trigger After Update is not cover using test class

I am writing a trigger On AgentWork with helper class. I have to write a trigger helper test class to cover helper class. Helper class successfully cover but trigger not cover for the helper test ...
0
votes
1answer
57 views

field change on child object auto populate parent field trigger

what am I doing wrong so that it only displays the new role? multiple roles should only be displayed if multiples are selected in the muli-select picklist. also, is it possible to have a space appear ...
0
votes
1answer
20 views

Populate Highest Segment on Parent Account

We have a Segment picklist field that separates our accounts by platinum, strategic, premium, ect. We want to have the parent account display the highest segment of all the child accounts which could ...
0
votes
0answers
30 views

Can I export attachments using Command Line Dataloader and use ANT to get it to FTP site/Google drive

Background: I want to run an after update opportunity trigger that would fetch all the opportunity records as well as attachments and then transfer it to a third party-website. In order to do that, I ...
0
votes
1answer
33 views

bringing Process Builder into trigger

I am trying to bring a process builder into a trigger and am having some trouble getting my apex class to know when a field changes. I've tried to research this and haven't been able to come up with ...
1
vote
3answers
76 views

Limitation with callouts

I want to listen to the change in permissions of salesforce records. For that, I am thinking to fire a callout from an afterUpdate method of a trigger. Whenever a record is updated through any means, ...
2
votes
1answer
36 views

How to Capture Approval Comments in Case Object Custom field called comments ? Below code i am getting an error trigger depth exceeded?

trigger CaseApprover1 on Case (after update) { List<ProcessInstance> instances = [SELECT Id,TargetObjectId,(SELECT Id, StepStatus, Comments FROM Steps) ...
1
vote
2answers
83 views

Hari Krishnan based Trigger Framework executes twice on After Update

I have a trigger framework based on the work by Hari Krishnan: An architecture framework to handle triggers on the Force.com platform, however I have functionality on After Update in wich a trigger ...
1
vote
0answers
21 views

Does Apex lead conversion trigger Contact before/after insert triggers? [duplicate]

I have some updates I'd like to make on converted leads. I had it in my lead code - first convert the lead, then query for the converted contact and update. However, that was triggering ...
1
vote
1answer
114 views

System.TypeException: Invalid integer: (Lead-0002)

I have created a round robin assignment of leads to users. I am getting the following error Lead_Trigger: execution of AfterUpdate caused by: System.TypeException: Invalid integer: (Lead-0002) ...
4
votes
1answer
58 views

Need help in optimizing the below helper class

Logic : For any new record inserts for 'Properties' object, check if its Account_Ref_Ext_ID__c equals to 'Account' object's Chris_Account_Number__c. If it matches, assign Account id to properties ...
0
votes
1answer
53 views

List must not have two identically equal elements: bulk test

I have after insert Trigger and I'm trying to test it with this logic (for bulk testing). It's a little test from Execute Anonymous Window: List<Lib__c> lb = new List<Lib__c>(); string s =...
-2
votes
1answer
27 views

Trigger after insert: can't update a record with no direct connection

I have this construction: If we create a Factory 2 with InDateTime__c = OutDateTime__c of the Tool 1 with the same Opportunity 1 (with another Factory 1 with the same Opportunity 1 relationship), ...
-1
votes
1answer
31 views

Whenever I update a account, if the account name contains 'test', it should be changed to 'test1'

Its working fine if the account name contains 'test' but if it contains 'TEST' or any other uppercase/lowercase combination other than 'test', its showing 'maximum trigger depth exceeded account ...
0
votes
1answer
189 views

After update trigger getting same old and new values in trigger.old and trigger.new

I have custom objects called Asset__c and Site__c. Asset__c has a lookup field to the object Site__c, which is called Asset_site__c. There is a formula field in Asset__c called Asset_Site_Name__c ...
0
votes
1answer
46 views

CPQ execution of AfterUpdate caused by: System.FinalException: Record is read-only

On CPQ quote object When we click on submit for approval button, status is changed to In review, when the status is changed to in review. I Have to populate a field from quote associated ...
0
votes
2answers
76 views

Update failed. First exception on row 0 with id ******; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadTrigger: maximum trigger depth exceeded

Error on Line 154: Update failed. First exception on row 0 with id ******; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadTrigger: maximum trigger depth exceeded public class ...
0
votes
1answer
64 views

I want to update Checkbox(Custom Field) on Contact whenever a new Opportunity is created based on Contact in (Primary_Contact__c)

I want to update Custom Field(Checkbox) on Contact whenever a new Opp is created and Opp has Primary Contact from Contact trigger PrimaryConOnAccOfOppHandler on Opportunity (after insert, after ...
0
votes
0answers
25 views

Can someone help me how to write Test Class [duplicate]

I just want to know how to write Test Code.. I've no Idea About it. If Someone can Explain me what are the keypoints to write a Test Class I've also tried to write Test Class. In this Test Class It is ...