Stack Exchange Network

Stack Exchange network consists of 175 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.

0
votes
1answer
36 views

isAfter && isUpdate is not triggering [on hold]

So I have created a trigger and a trigger handler class, but I cant seem to make either of them trigger in an isAfter && isUpdate call. My updateInstallStatusDesign works fine when it is an ...
0
votes
2answers
28 views

Need to Understand Apex trigger soql execution on each events

I have a trigger handler as shown below (Please Ignore any Syntax errors) trigger AccountTrigger on Account (after delete, after insert, after undelete, after update, before delete, before insert, ...
0
votes
0answers
30 views

INVALID_FIELD, All accounts must have the same current owner and new owner.: [OwnerId]

I am trying to cascade the same ownerid across all contact owners within an Account Contact Relation hierarchy. I wrote a pretty basic after update trigger on an account to accomplish this. When all ...
0
votes
2answers
26 views

Apex trigger to execute after batch is finished?

I have 2 Orgs let's call them A & B. I have a process that queries org A and transfers data into Org B. For simplicity, let's say OrgA.Id OrgA.ManagerID After my upsert I end up with a record ...
0
votes
1answer
25 views

Error while adding validation rule on status field on close case page

I am writing a validation rule to add a error message on case close page, if user trying to change the case status to resolved for the already resolved cases then it should through an error stating ...
0
votes
1answer
20 views

How to Deserialize the Trigger old & newMaps in JSON

I'm trying to pass the old & newmaps as arguments to a future method using JSON method. I see the below error when it tries to deserialize the data. reference-Passing SObjects to Future |...
-2
votes
2answers
22 views

Whenever an account name is modified send an email notification to the contact of an Account

Trigger is not go into the If Condition and Not compare Value. How to comapare oldAccount Name is notEqual to ModifiedAccount Name? And How to write query for the Id to compare the Name in the code.If ...
0
votes
2answers
39 views

Apex Trigger Order Of Execution

Correct me if my understanding is wrong - All the DML operations are committed only if the entire code runs successfully. I've carried out the following activity: Written a block of code which will ...
0
votes
0answers
30 views

Trigger to fire after 10 seconds only ONCE

I have a use case where I need to do an Aggregate SOQL on OpportunityLineItem(oli) & its opportunitylineitemschedules(olischedules). I have 2 triggers(Trigger1 on Opportunity & 1 on oli). On ...
-1
votes
1answer
36 views

Platform Events Subscription through Trigger and parsing a JSON payload field [closed]

We are going to implement platform events for inbound integration and subscribe to events using trigger. Among the platform event object, one of the fields is a long text area which has a JSON payload ...
0
votes
1answer
24 views

Could not able to retrieve VersionData from Content Version after insert of ContentDocument

I am trying to retrieve the body of ContentDocument after insert. Below is my code.My trigger is on ContentDocument (After Insert) public static void syncContentDocument(List<ContentDocument> ...
0
votes
2answers
20 views

AffterInsert PROBLEM

I am attempting to update a field on the Opportunity object with the project that gets created (that is associated to the opportunity) So basically the way things work is that when an opportunity is ...
0
votes
1answer
36 views

Repeated invocations of Trigger Dispatcher. Logs not helpful

I have a method in a trigger dispatcher that's being called in a recursive but seemingly untraceable fashion. The following log entries just repeat over and over until I reach maximum stack depth. ...
0
votes
1answer
16 views

How to abort Cronjob by name?

I have cronjobs which are scheduled in after update trigger. When some user make an update in one and the same record I need the previous cronjob(batch) to be aborted and to start a new cronjob. How ...
0
votes
1answer
49 views

Why is (Trigger.isInsert && Trigger.isAfter) not firing when running test class?

THE PROBLEM: My CustomObjectTrigger has a CustomObjectHandler class. I have code that is fired in the CustomObjectHandler class when the CustomObjectTrigger is fired by a new record that (isInsert &...
-2
votes
1answer
24 views

While Refering to the Account field why it will give error that variable dosenot exist please help

public class LeadHandler { public static void callme(List<Account>acc){ for (Account a:acc){ if(a.Type=='prospect'){//While refering Type it give an error ...
0
votes
1answer
29 views

update a field on contact once i associate a account

i wanted to update a field on contact once i associate a account. once accountcontactrelation is created i am checking if that relation role is Manager and if yes then only i wanted to update a ...
0
votes
1answer
38 views

Apex class INT_InteractionProcessor error- issue with Mailing City Mapping

Using a Webform (FormAssembly) to create an Interaction & Getting an error. Using the same form multiple times. it sometimes errors at the first submit and sometimes after the third submission, I ...
3
votes
3answers
348 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
45 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
30 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
38 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
23 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
28 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
253 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
150 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
93 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
30 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
30 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
36 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
33 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
46 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
29 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
82 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
824 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
31 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
46 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
36 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
110 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
63 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
30 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
271 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
61 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
184 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
53 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
110 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
102 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
45 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 ...