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.

-1
votes
0answers
14 views

Lead Reassaignment. Can we do this with one trigger and class Combination [on hold]

acitve --> No Chnage inactive - > user --> manager is active --> assigned to manager inactive --> user --> manager is empty --> assigned to unassigned inactive --> user --> manager is ...
0
votes
1answer
42 views

Consuming a REST api in Salesforce

I need to create an integration between Salesforce and a third party service. Essentially Salesforce will trigger a callout to the third party when a status change occurs on a custom object record. ...
0
votes
2answers
37 views

Apex after insert trigger - variable does not exist

I am calling another class from my trigger and it works in sandbox, but when I try to validate my deployment (I am using a change set to deploy) in prod, it says "variable does not exist: ...
0
votes
2answers
24 views

Follow Up Task in creation of new Task

I am getting bit confused on the probable answer as to what would happen on executing the below code block (considering trigger event as After Insert and scenario as to Create a Follow Up Task ...
0
votes
0answers
19 views

Method does not exist or incorrect signature: void setToaddress(List<String>) from the type Messaging.SingleEmailMessage [duplicate]

trigger mailsentcreateaccusindtri on Account (after insert) { //list<string> mail= new list<string>(); if(trigger.isafter && trigger.isinsert) { list<...
-1
votes
1answer
32 views

Trigger; Initial expression is of incorrect type, expected: String but was: List<String>

//trigger code trigger mailsentcreateaccusindtri on Account (after insert) { //list<string> mail= new list<string>(); if(trigger.isafter && trigger.isinsert) { ...
0
votes
2answers
61 views

How to retrieve Parent's Id of a triggered child record, inside the trigger - Solved

Certification__c(Parent object) --> Exam__c(Child object) Trigger triggers when Child is updated. trigger certificationToFailedNew on Exam__c (after update) { //List out all the exams associated ...
0
votes
1answer
26 views

Execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject () [duplicate]

Heres the error that I'm getting: Execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject () I believe the issue is with the following lines, which aims ...
1
vote
1answer
34 views

Insert and return in test data factory

Why do we sometimes add a new record to an object and then just return the variable and sometimes we insert it too. I am confused, can somebody clarify me on this?
0
votes
1answer
27 views

Task execution of AfterInsert Error for Task Trigger CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY

So I have a trigger and a class that works perfectly when I manually test in sandbox but when I run a test class, I get the below error: 13:50:50:330 EXCEPTION_THROWN [49]|System.DmlException: Insert ...
0
votes
0answers
43 views

“Apex trigger SBQQ.OpportunityAfter caused an unexpected exception message when on a opportunity and click on ”Contracted" checkbox

I got this in my email Error type: SBQQ.ContractService.ContractServiceException Reason for error: A primary quote is not specified for this opportunity. Please make sure you have the primary ...
0
votes
2answers
83 views

How to avoid Select statement in my for loop?

List<Checklist__c> newCheckLists = new List<Checklist__c>(); Map<Id, Account> legalStructAccount = new Map<Id, Account>([SELECT LegalStructure__c FROM Account WHERE Id IN (...
0
votes
1answer
55 views

How do I insert a multiple list of records into an object which is from the result of a SOQL query in trigger?

I get multiple records from the records list and now I want to insert as new records in an object. Should I create a map or should I do that? records output is checklistTemplate__c:{Name= Test, Id = ...
-1
votes
1answer
26 views

How to query the result of a SOQL query as IN subquery in another SOQL query?

I am trying to use the result of a query to be used as In another query but I am getting an error. How do I solve this? trigger CopyChecklistIntoLegitimation on Legitimation__c(after insert){ //...
-1
votes
2answers
42 views

Update trigger map issue [duplicate]

Edit: I've gotten stuck trying to get my test coverage above 64% on this trigger. When I update the test record, I get coverage for the Follow_Up_Date__c field change but not for applicationMap.put(...
0
votes
2answers
91 views

Non-selective query against large object type (more than 200000 rows) error in trigger

Followed trigger best practise.No queries inside the for Loop. Error Msg: caused by: System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an ...
-1
votes
1answer
25 views

Auto creating subfolders in box.com through salesforce

Below is my code for auto creating the folders in opportunity but it is throwing me the below error for my code... Error: List has no rows for assignment to SObject Code: public void ...
0
votes
1answer
36 views

Variable does not exist: StageName what is preventing from saving my apex class which i am calling from apex trigger

This is my Apex Trigger trigger OpportunityUpdateTrigger on Opportunity (after Update,After Delete,after Undelete,before Update) { if((Trigger.isAfter) && (Trigger.isDelete)) { ...
0
votes
1answer
47 views

How to identify similar records in a List and then updating corresponding fields

trigger setCertificationToFailed on Exam__c (after update) { List<Exam__c> ExamList = new List<Exam__c>(); ExamList = [SELECT Id, Exam_id__c, Exam_state__c, doNothingExam__c, ...
-3
votes
1answer
27 views

Trigger on custom object to send email after uploading all the mandatory documents [closed]

trigger MandatoryDocumentsUploadedEmail on Verification_Documents__c (after insert) { if(Trigger.isAfter){ if(!Trigger.new.isEmpty()){ Set<Id> oppIds = new Set<Id>()...
1
vote
2answers
268 views

Why do we need to update related records in an after trigger but not before?

Why do we need to write the logic to update a related record in an after trigger but not before? Update triggers(Before/After) will have both the record ID and the related record's ID so why can I not ...
0
votes
1answer
41 views

isAfter && isUpdate is not triggering [closed]

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
41 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
56 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
47 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
36 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
27 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
25 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
49 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
36 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
111 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
148 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
22 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
39 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
17 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
171 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
30 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
44 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
353 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
47 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
31 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
40 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
37 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
372 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
246 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
99 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> ...