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

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.

3
votes
3answers
304 views

How can I know if it's the last execution of an After Trigger?

Imagine one object with 20 fields, field1 to field20. Some of these fields I have Process Builder in place, some of them I have Worflow Updates, and some of them are 'bare field' (i.e. PB and WF does ...
-2
votes
1answer
40 views

recursive trigger on junction object

I'm getting an error while updating status how to avoid it trigger applications on Job_Application__c (after update) { set<id> candiadteIds = new set<id>(); List<...
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 ...
2
votes
1answer
37 views

Failure setting lookups in triggers when upserting multiple records of different types very quickly

I have an integration app that polls records of different types from an internal database every few seconds and upserts them into Salesforce. I have two pollers that run independently from one another ...
0
votes
1answer
22 views

Compare a record with another record within a for loop and update the record accordingly

Here is my scenario. I have a custom object Milestone, child of Opportunity. When a milestone is marked as Status = 'Completed', then the trigger should populate the Start Time of next Milestone in ...
0
votes
1answer
21 views

rest post execution of AfterInsert caused by: System.NullPointerException: Argument cannot be null

i am doing an callout to a third parity using a trigger. and I am getting the error. CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY message: LeadCallout: execution of AfterInsert caused by: System....
0
votes
2answers
32 views

Create list of records in Before and delete the list in After Context

I need to write a trigger on Case object where I need to delete the placeholder records and relate the case to existing records. I need to prepare the list of placeholder in before context and delete ...
0
votes
1answer
159 views

Test Class for Content Document Link trigger

I have created a trigger functionality on after insert of content document link, trigger functionality is working as expecting. But when i have written a test class to insert test record for ...
0
votes
1answer
96 views

Using Maps instead of nested for loops in APEX

Hi i'm really new to Salesforce development in the following code I'm trying update existing record to inactive but, not the coming record on two different conditions. I'm a bit confused in the last ...
4
votes
1answer
83 views

Why won't Apex IF statement work in Production Unit Testing after working in sandbox?

this is driving me NUTS and any thoughts are MUCH appreciated after looking at this for far too long. Use case: users in certain profiles need to be automatically added/removed from a particular ...
0
votes
1answer
28 views

How can I test Messaging.MassEmailMessage with checking targetobjectids?

We have some User with UserRole. I need to verify that the email has been sent to the user with the role 'TestRole'. How can I do that? I try: List<Messaging.MassEmailMessage.targetobjectids> ...
0
votes
1answer
26 views

Same Logic for after insert and after update trigger?

I have to implement same logic x=y+z for after insert and after update trigger on an object. Unfortunately I cannot make use of context variables as our prototype for trigger handler is defined long ...
-3
votes
1answer
32 views

Test class with different scenarios for trigger helper

I have 100% coverage, but I still haven't scenarios for check. How to write good and bad scenarios for test class? This is my helper: public with sharing class JobHelper { public static List<...
0
votes
2answers
32 views

Can I avoid a code duplication here?

I have a code duplication here. How can I fix it? I want to make my code better. Helper: public with sharing class JobHelper { List<Task> taskList = new List<Task>(); public void ...
0
votes
1answer
39 views

How to make more methods in Trigger Helper class?

How can I make more methods in this Helper class, not just public static void? I also need a method for checking the update of Stage__c field (when we update another fields - Trigger shouldn't be ...
0
votes
1answer
27 views

Pass Subject and Description in new Case

I have an after insert trigger that is updating cases and I want to be able to pass Subject and Description on with casesToUpdate. Below is the code. I do not want to change the Subject or Description ...
0
votes
4answers
47 views

trigger when check box is check automatically create child record

Create the field called "Contact Relationship" checkbox on the Contact Object and Create the related object called "Contact Relationship" which is related list to the Contacts.(Look Up Relationship). ...
2
votes
1answer
611 views

APEX Lock and Unlock a Record

I wanted to lock and unlock records based on a check box. I know that you can do this stuff via a validation rule but I think that is difficult to maintain if adding fields. I wrote an apex trigger ...
0
votes
1answer
27 views

Unable to create Auto EventRelation record via trigger

I am trying to create an EventRelation record on insert of an Event. Basically I am trying to add WhoID of Event into invitees automatically. Am I missing anything. I am not getting any error also. ...
1
vote
2answers
45 views

Best way to process the records in After Update triggers - Sets or Lists

This may be a very primitive question but am failing to choose the best way and am trying to follow the best practices. We have many Salesforce Apps implemented, as a result there are many record ...
0
votes
1answer
34 views

Email sent twice on trigger

I have a requirement where I'm sending an email and also creating an email message record when certain conditions meet. However, the email is shot twice and 2 email message records are being created. ...
-1
votes
1answer
98 views

after insert,after update trigger doesn't work

Below is my trigger to create a new record(with next quarter) when Hold and freeze are set to true. But this works for new but not update. below is my trigger and . trigger AddingNewQuarter on ...
2
votes
1answer
62 views

Logic written in AfterInsert does not finish when beforeUpdate is called

We are creating OpportunityLineItem through Apex, now in isAfterInsert we are creating a Test object record whose Unique_Key is same as OpportunityLineItem unique_key. Now attaching the 'Test' to ...
1
vote
1answer
26 views

Why doesn't my code enter for loop when record found?

I have an object(Huishouden__c) with a related list. I loop trough the object records with a for loop on the related record. When I debug the object in the first loop I get an Id but it does not enter ...
1
vote
1answer
201 views

How to perform DML operation in after insert, after update trigger

I am new in developing apex. Here is my trigger. When I try to update an account record, I get the error: " Error:Apex trigger pfUpdate caused an unexpected exception, contact your ...
1
vote
1answer
58 views

How write tigger Insert & update other records same object with update query

I have this trigger where I insert a record. On the insert I want to check on birthdate and set a checkbox on true for the record with the oldest birthdate related to same Household/Huishouden__c. ...
-2
votes
1answer
40 views

Platform field value isnt updating in Document Level through Junction Object [closed]

Object structure: #Platform #JunctionPlatformDoc (junction object) #Document Platform contains its name and aircraft manufacture sosl field. I have to populate those fields in document Level, In ...
0
votes
1answer
132 views

Maximum trigger depth exceeded error while update

am getting the following error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Effectivefilingdate: maximum trigger depth exceeded Patent trigger event AfterUpdate below is my code-what is the change i ...
0
votes
2answers
48 views

How to populate owner name instead of id from a child object

Here i am trying to get owner name value from child object incident , OwnerId is populating correctly but when i tried with Owner.Name, value is coming null in debug log. Please find my piece of code ...
0
votes
1answer
85 views

Update a record based on the field update on any grand child record

I have three different objects A (Grand Parent), B (Child) & C (Grand Child). All the three objects are related by a lookup relationship. Now, there is field on A object, IsActive which is a ...
1
vote
0answers
94 views

Insert operation triggering NOT(ISNEW())

I would like to ask for help regarding why an insert operation would trigger and fail this validation rule: AND(NOT(ISNEW()), ISPICKVAL(Pipeline_Type__c,'Licence'), ISBLANK(Related_Pipeline__c)) The ...
0
votes
1answer
37 views

Accessing variables between visualforce page to controller classes

The following code is called from Opportunity trigger. So the flow is From opportunity trigger call MyTwiMLController.processoutboundCall() After the callout it calls the VF page "TwiMLPage" Then it ...
0
votes
1answer
50 views

Create Test Class for the simple Trigger

I'm writing a simple trigger for Contacts. But my coverage is 19%. Can anyone help me figure it out? My Trigger: trigger ConCase on Contact (after insert) { List<Case> CaseList = new List&...
0
votes
1answer
96 views

Formula not having updated value in After Trigger : Apex Trigger

updateTemplate((List<Object>)tp.newList, (Map<Id, Object>)tp.newMap, (Map<Id, Object>)tp.oldMap); In the method I am querying updateTemplate I have a query as below Map<Id, ...
0
votes
1answer
28 views

Triggering after update - difference between UI and Setup for Picklist value changes

I have discovered that if I change a picklist value from the UI, it triggers apex after updates, as well as Process Builder flows, while if I use the Picklist field window, and 'del/replace' the ...
0
votes
1answer
35 views

Trigger not fire

I have Case(Parent), Enquiries(child) objects. When Enquiries status is not equal to Processed then Case should not be closed. I have written trigger on child object. It's not working. trigger t on ...
0
votes
1answer
83 views

Error updating custom Salesforce object using Talend ETL - Status Code: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

I am trying to update the name of one of the Salesforce Custom Objects, and using Talend Data Integration tool for the same. The action on the salesforce Object is 'Update' and I only have two columns ...
0
votes
0answers
27 views

Existing Records Not Retained After Inserting New Records

My trigger consists of after insert event. This runs on ObjectB__c object. The requirement is to add new records on ObjectF__c after insert of ObjectB__c record. Inserting of ObjectB__c record is one ...
0
votes
1answer
791 views

After Delete trigger not working

I have written trigger on afterdelete. I have checkbox OpenOpportunity on account when i delete the open opportunities stages from account related opportunity then OpenOpportunity checkbox on account ...
0
votes
2answers
817 views

Method does not exist or incorrect signature: void containsKey(Id) from the type Set<Id>

I am getting the following error on line 12 and 25 and would need some help in resolving it. Error on line 12: Method does not exist or incorrect signature: void containsKey(Id) from the type ...
1
vote
1answer
152 views

Unit test keeps failing an “Insert” Campaign Member Status Apex Trigger (works in UI)

I am trying to write a Unit Test that passes an Apex trigger for inserting 2 custom CampaignMemberStatus records. The trigger is performing as expected in the Sandbox UI as an end user, however it ...
2
votes
2answers
779 views

How do reference a related object within a Salesforce Trigger?

How do reference a related object within a Salesforce Trigger? I am creating a record for a related object and need to assign a value to one of the fields in the new related object (relatedOject1) ...
1
vote
1answer
145 views

Test class silently fails to add product?

I have a trigger that executes on after insert and after create on the Opportunity that updates fields on the OpportunityLineItem Object. Code works but the test class opportunity does not appear to ...
0
votes
1answer
239 views

Salesforce trigger Opportunity and Opportunity product

I am working on a requirement to create an opportunity and opportunity products , when there is an update on the asset object. The asset object has a filed called Refresh_Asset_To__c, this is a ...
-1
votes
1answer
89 views

Update failed error in my trigger

Trigger trigger Account_AU on Account (before insert, before update, after insert, after update) { if(AccountTriggers.toBeExecuted){ if(Trigger.isBefore) { if(Trigger....
1
vote
1answer
59 views

Case owner not able to change case owner after insert

I am trying change the case ownerid to Queue but getting System.FinalException: Record is read-only error in after insert. Below is the my code: if(Trigger.isInsert && Trigger.isAfter) ...
-2
votes
2answers
106 views

Contact Score Rollup on Account Object

I have to calculate the sum of related child object(contact) on field (Score1__c and Score2__c) to parent object Account object field(AccountScore1__c and AccountScore2__c) my code is working on ...
0
votes
1answer
147 views

Unable to set pricebook Id in orderitems

I am writing trigger "On Insert Of Order(Sales order) copy opportunityLineitems to order line items" I have done everything fine upto my knowledge but when I am inserting order it is showing pricebook ...
0
votes
3answers
221 views

Write a trigger on Quote object to populate that “Sales Tax” (Lookup) according to: Bill to State/Province Bill to City

Experts, I had been working on this issue for quite a few days but with no luck and need your help. 1.) Create a new object Sales Tax: Fields: City: Text State: Text Sales Tax %: Percentage 2....
0
votes
1answer
28 views

Can I update an account field when an email is sent from that account?

How can I update an account field called "Last_Contact" when an email is sent from the account with the created data of that email? I tried doing it via a field update and starting building the ...