A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

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
2answers
78 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 ...
2
votes
2answers
53 views

trigger to update Custom field on Account record whenever a new opportunity record (Whose Title contains 'CEO') is inserted or deleted

Trigger to update Custom field(Count_Of_Title_in_Opp__c) on Account record whenever a new opportunity record (Whose Title contains 'CEO') is inserted or deleted Trigger trigger OppSizeOnAccount on ...
1
vote
2answers
68 views

Trying to update Values in Standard Object from metaData

Trigger is updated to Before UPdateI am using Trigger isBefore In System.debug(opp.get(metaData.get(0).Opportunity_Field_Name__c) it is showing correct Values but not Updating in Opportunity Object ...
1
vote
2answers
58 views

How to convert this trigger to apex Class

I've written this trigger to Update Total Numbers of Contact in related Account Custom Field... All Code is written in Apex Trigger However, I've been told that it's best practice to split this into ...
1
vote
1answer
41 views

trigger to update a custom field in account when related opportunity is created with same value as in custom field of Opportunity

Can someone please elaborate what is mapAccounts.get(opp.AccountId) is getting here MapAccount acc = mapAccounts.get(opp.AccountId); trigger OppTrigger on Opportunity (after insert) { if(...
2
votes
2answers
53 views

trigger to update field on Account record whenever a new Contact, opportunity record is inserted or deleted

Number fields on Account : "No of Contacts" Write trigger to populate/update field on Account record whenever a new Contact record is inserted or deleted. -- whenever i am deleting last contact ...
-4
votes
1answer
75 views

Trigger not creating a new record [closed]

If case status got change for certain record type, new support record should get created. I configured status and record type combination in custom setting I am trying to avoid nested loop in my ...
2
votes
0answers
81 views

DescribeFieldResult.getReferenceTo returns only one type in a specific scenario

I am seeing some strange behavior where DescribeFieldResult.getReferenceTo returns only one type for the Lead.OwnerId field in some cases when invoked in a trigger context. The code below displays ...
0
votes
1answer
26 views

upsert from apex trigger

How can we upsert records to glocal picklist values from trigger? I wanna get existing records from a custom object and upsert the records to glocal picklist value by trigger. What type of trigger ...
0
votes
1answer
45 views

Why are field updates inside an Apex trigger not showing up in an Apex test?

I have a very strange issue with some Apex tests for a trigger. The tests each check a different type of field update; when one field is changed, the trigger is supposed to change another field. On a ...
0
votes
0answers
20 views

Accounts are in the wrong Company Group and failing to create new Company Group

I need help to find error in my trigger. I have created trigger for the following points but its failing to create Company group. Could you please see and suggest me. Contact is the parent of Company ...
0
votes
1answer
38 views

bypass trigger on specific object in salesforce

I need to bypass trigger on account sometime. I have created custom setting for that and added triggerObject__c field. In my code bypassTrigger__c bypass = bypassTrigger__c.getInstance(UserInfo....
0
votes
1answer
72 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
54 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
353 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
24 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
131 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
64 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
79 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 ...
2
votes
1answer
115 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
47 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
251 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
94 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
60 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
45 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
47 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
113 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
55 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
55 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
28 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
760 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
45 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
50 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
1answer
171 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
102 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
66 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
51 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
89 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
81 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
80 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
228 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
287 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
46 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
29 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
460 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
25 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 ...