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.

54 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
3k views

ContentDocumentLink Apex after insert trigger error

Edit: I've built an after insert trigger on ContentDocumentLink. On cropredy's direction, I've bulkified my code and I think improved it generally. It "works" in that it accomplishes my ...
2
votes
0answers
48 views

Problem with trigger time executions

I have 2 triggers after insert wich call one apex class each one. One of them call an apex class for make a query to get an Id from the first trigger execution. I need this ID to match two differents ...
2
votes
1answer
77 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) ...
2
votes
0answers
151 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 ...
2
votes
0answers
578 views

AgentWork trigger is not firing before or after insert events

I have created an after/before insert trigger defined on AgentWork object. When a case is created from Email to Case, the record is automatically routed to an available Agent from a queue by Omni-...
2
votes
2answers
506 views

After insert trigger not reading lookup values

I have object customObjectA__c which has a lookup fields - lookupfield1__c I have an after insert trigger which, at some point, checks if that field is populated. The whole issue is, it's reading ...
1
vote
1answer
61 views

Trigger to update all children not giving expected results

I'm replacing a formula field (due to hitting the max number of 15 object references) with a trigger on Account (after insert/update) and on Contact (before insert/update). There are three account ...
1
vote
0answers
213 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 ...
1
vote
1answer
319 views

Insert/Update Record on other Object

Requirement :- Need to Insert records in to Custom object (Merged_Account__c) and Update when Account with same id already present in Merged_Account__C. Merged_Account__C Object having custom fields(...
0
votes
0answers
14 views

Feed Item records not found in test class flow

I have a requirement to purge all chatter feed that are auto created when case comments are inserted. Hence I am deleting all FeedItem records of type CaseCommentPost via CaseComment Trigger. Below ...
0
votes
0answers
28 views

Creating Trigger and Test Class for it. “Overall Code Coverage” always 0%

I have created following trigger: Trigger updateTotalAddCost on Ad_Cost__c(after insert) { for (Ad_Cost__c a:Trigger.new) { Campaign SearchCampaign = [SELECT Id, Name, Ad_Cost__c FROM Campaign ...
0
votes
0answers
34 views

INACTIVE_OWNER_OR_USER, owner or user is inactive

I got an issue when I want to load (data through Talend) to Salesforce. When I do the upsert, I have like 50% of upsert errors with this message : CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:UserTrigger: ...
0
votes
0answers
24 views

new instance of object creation for updating a record

Requirement-I have custom object request__C where i am storing sourceAccount ID and TargetAccountID. My requirement is to update the field in request object with max contact in any of the account. ...
0
votes
2answers
36 views

Not able to get max amount and update the status in Apex

i have requirement where i need to get all orders from account and need to check max amount from that order and need to update the status of order to InProgress. then from account1 ==>order4 needs to ...
0
votes
0answers
49 views

Trigger not deleting older Event Relations IDs when bulk updating

This is a follow-up question to my previous thread AfterUpdate caused by: System.SObjectException: Field is not writeable EventRelation.RelationId . Code updates fine for 5 records but when I tried ...
0
votes
1answer
16 views

Access audit trail data outside of salesforce

I need to pass audit trail data to informatica. Can anyone suggest how informatica extract the data. is there any way to query audit trail or any standard api to fetch data
0
votes
0answers
31 views

UNABLE_TO_LOCK_ROW

Error while saving Quote Lines:SBQQ.ValidationException: [": execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable ...
0
votes
0answers
54 views

Error: Compile Error: Invalid type: DuplicateRecordItem

i am writing a trigger on account object on after delete event . scenario: once Account records are merged the trigger should delete corresponding Duplicate Record Set record. code: public static ...
0
votes
1answer
25 views

Trying to understand correct logic for before and after trigger

I am new to apex and have wrote a trigger on the lead object that updates fields on the record, and also creates tasks associated with the record. I have set up the code for both of these ...
0
votes
0answers
13 views

Populate Contact Custom Picklist Filed Value in Account's Custom FIeld

I've Created a custom picklist field on Contact 'Contact_Rating__c' with the values High, Medium, Low and created 2 fields on Account 'ContactHighestRating__c , ContactNameWithHighestRating__c' if ...
0
votes
0answers
53 views

Trigger Error on Bulk Upload

I am trying to upload bulk Contact records into salesforce through import wizard for code quality check. While doing so i found the following error. CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:Too many ...
0
votes
1answer
30 views

Exception in trigger, fail to update the field on account which is used to count the number of contact with specific type

Please help me out. I posted my trigger please it throws the exception Exception Details: Update failed. First exception on row 0 with id 0035000003IGI8AAAX; first error: ...
0
votes
0answers
38 views

Apex Trigger Error

Here is my Apex Class: public class NavProductHelperClass { public void checkProductAvailability(list<OpportunityLineItem> opids) { for(OpportunityLineItem oli: opids) { ...
0
votes
1answer
105 views

Test Case - Attempt to de-reference a null object (Formula Field)

Now I have 0% coverage. System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CaseHandlerCountAlert: execution of AfterInsert caused by:...
0
votes
0answers
23 views

CPQ-Custom field blank value email template after submit for approval on Quote

On CPQ Quote: I am a newbie to salesforce and CPQ. When quote is Submitted for approval, email templated is triggered named quote submitted for approval from CPQ package.In that email template custom ...
0
votes
0answers
60 views

Can I export attachments using Command Line Dataloader and use ANT to get it to FTP site/Google drive

Background: I want to run an after update opportunity trigger that would fetch all the opportunity records as well as attachments and then transfer it to a third party-website. In order to do that, I ...
0
votes
1answer
34 views

bringing Process Builder into trigger

I am trying to bring a process builder into a trigger and am having some trouble getting my apex class to know when a field changes. I've tried to research this and haven't been able to come up with ...
0
votes
1answer
363 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
2answers
221 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
74 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
1answer
49 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
1answer
71 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 = ...
0
votes
2answers
191 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
0answers
102 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 ...
0
votes
1answer
36 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
491 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
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
48 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 ...
0
votes
1answer
200 views

After Update Trigger to update parent status when child status is updated

I have a requirement to update parent status when child status is updated. Service is a child object and subscription is a parent object.Service has a self lookup.If child services status is updated ...
0
votes
1answer
39 views

Need a help for validate trigger on lead

I have written one trigger on Lead- Requirement:- On Insert/update Lead,If Leadsource is "Web" and if Lead company matched Any account Name then Populate the Id of that lead into ...
0
votes
1answer
29 views

Track of account records into alternate contact (custom object) records

We need to track any change in billing Address ( address,city,state,zip) of Account in a new Object : ÄLTERNATE CONTACT (Address, City,State, Zip, UpdatedDateTime, Account) . This object should ...
0
votes
0answers
336 views

How to use current record Id (In after insert trigger) to save it in some different object?

Please find my scenario below I will talk in generic words so that the objects name should not confuse someone. I have written after insert trigger on an object and obviously, I am getting the Id of ...
0
votes
2answers
86 views

Apex Trigger on OpportunityLineItem: Attempt to de-reference a null object error

I've been trying to figure this error out for a while now and it seems that I just can't figure it out. When adding an opportunitylineitem to an opportunity, I keep receiving the error "Attempt to ...
0
votes
0answers
255 views

Automate Chatter Post to Specific Users When Creating Log a Call Record

I'm hoping that there is someone who can assist me with an automation/trigger question with regard to using Log a Call and Chatter integration. When using Log a Call, one of our teams has requested ...
0
votes
0answers
65 views

Converting a Trigger into a Class Auto follow in chatter

I am very new to Apex, and was hoping that someone could help me. I do have a trigger in place, but would like to convert it into a Class. I will be calling this class from a new trigger, but I lack ...
0
votes
1answer
28 views

Need to update a field in case based on certain conditions in child object

I'm trying to update a field called Survey Sent field on case object. But before this update that there are certain fields on the child object, which impacts on update on survey sent on case object. I ...
0
votes
1answer
78 views

Open to opportunity instead of contact after lead conversion

I was able to reuse code from the another post to successfully convert a lead and have it open to the Opportunity after the conversion. But that code bypasses the VF page that lets you match up to ...
0
votes
1answer
35 views

Error in Trigger used for creating records in Opportunities based on the Campaign Members

I had a requirement where i need to create records based on the Campaign Members in the Opportunitie.i had done the trigger and the code was working fine but today i had an error Error:Apex trigger ...
0
votes
2answers
82 views

I am not able to run this trigger on contacts related to accounts

what i am trying to do is make a trigger on contact in which field acc_number__c is updated in Contact from the account field acc_number__c if the checkbox field final_number__c is selected in the ...
0
votes
1answer
251 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 ...