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
2
votes
1answer
22 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
35 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
17 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
27 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
56 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
33 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
26 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
25 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
63 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
35 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
30 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
52 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
24 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
44 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
56 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
48 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
21 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
47 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
73 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 ...
0
votes
1answer
19 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
41 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
18 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
32 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
45 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
40 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
50 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
22 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
53 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
62 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
39 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
50 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
29 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
78 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
86 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
43 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
96 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
32 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
38 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
436 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
44 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
45 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
102 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
58 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
39 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
35 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
59 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 ...