Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen 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
187 views

Cannot Update WhoId on Task, No Error Given

The following class is called during an after insert trigger and handed trigger.NewMap. Per my debugs the task whoid is updated, however when I look at the task record the whoid has not been updated. ...
0
votes
3answers
1k views

Showing number of contacts in each account object

i created new custom field (Count_Of_Contact__c). then i written the trigger for update the related contact count, but did mistake. it showing: Compile Error: unexpected token: ')' at line 6 ...
3
votes
1answer
116 views

trigger working as expected from UI but not from data loader/workbench

I have written one trigger.It is working as expected when i am updating owner from UI. but it is not working when i am updating from DataLoader. Requirement :- in Lead description - add Lead owners ...
0
votes
1answer
39 views

Need to check trigger perfomance

I have created one trigger which checking if account owner and associated contact owner is same or not.Its giving me output correct.but when i am updating account using dataloader then its looping in ...
0
votes
2answers
77 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
122 views

update trigger issue [duplicate]

The trigger is giving me an error CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY . Maximum trigger depth exceeded. Now this trigger is working f9 in after insert event but i want it after update. I can't ...
-1
votes
1answer
298 views

Assign map <Id,Set<String>> in trigger

I have below code where I need Map<ID,Set<String>>, but I am unable to assign that value and it shows error. Can someone please help me? Apex Code // User - Terr Name Map<Id,String&...
2
votes
1answer
469 views

Delete/Prevent trigger on Feed Item

The initial idea was to block all chatter feed from external batch jobs which run nightly. We had a trigger do it. trigger PreventPost on FeedItem (before insert) { if(UserInfo.getProfileId() == '...
0
votes
2answers
124 views

Update all Contact owners when custom field on Account changes

Apologies in advance as my understanding of Apex is pretty bad... I'm attempting to create a trigger that updates the owners of all Contacts within an Account when a custom user lookup field on the ...
0
votes
1answer
196 views

Get List of GrandChild in a Map of Parent Id and List of GrandChild

There is hierarchy of Objects as Account - Opportunity(child) - OpportunityCHild(grandChild) In this OpportunityChild is a grand child of Account. I want to create map as Map<AccountId,List<...
0
votes
0answers
288 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 ...
1
vote
1answer
1k views

Execution of AfterInsert caused by: System.FinalException: Record is read-only

I am creating a cross-objects trigger that whenever a new opportunity is opened, the trigger goes to check whether the company has sold the same product to the customer before; if so, the type of the ...
-1
votes
1answer
129 views

Help to Matching the two different Object Records?

Could anyone help me to matching the field with two different objects 1.I Have two objects 1.Case 2.custom object Integration__c.here i'm tring to get the matching the some fields of both objects. ...
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 business ...
1
vote
1answer
159 views

Incompatible key type object for Map<id,account>

I am trying to write apex code (and I'm learning how) to roll up data from the on the Account from an object with a lookup relationship to the object. Fields from Account: ID, DealCount__c Fields ...
0
votes
1answer
64 views

How to assign case to custom object record using trigger?

Trigger : trigger CaseUserAssiginingTrigger on Case (after insert,after update){ //part-1 List<ID> ids = new List<ID>(); for(Case c : Trigger.new){ if (c.Reason != null) { ...
0
votes
2answers
70 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 ...
2
votes
2answers
2k views

How to avoid this “Too many query rows: 50001”?

I have an afterInsert trigger for finding duplicates leads and if duplicate lead is inserted take its values and put it in a custom object record and lastly delete this new duplicate Lead record. It ...
0
votes
2answers
145 views

Triggers inserting child record twice?

I have two objects opportunity and price study.Both are related using lookup relationship. In Opportunity I have picklist called Rule__c with value "rule" and others.when I select a value "rule" I ...
0
votes
0answers
215 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 ...
2
votes
0answers
475 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-...
0
votes
1answer
1k views

TestClass User Creation and system.runAs()

I have a requirement for a Trigger on Opportunity while creating a new Opportunity as, Add the Opportunity Owners Manager to Opportunity Team Member with role "Sales Manager" And if Opportunity Owner ...
1
vote
2answers
62 views

Creating/updating new object based on a logic in a trigger

I have two object , abc__c and xyz__c. xyz__c has a field named key__c which should store the id of abc__c object. abc__c has a picklist field status__c which can have different value "In-progress" , ...
0
votes
0answers
64 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 ...
1
vote
1answer
42 views

how to finding the duplicates in the map of lists?

I have a requirement.for that I create a trigger. on that trigger I am using the Opportunity -Sobject and List of OpportunityContactRoles comes under the opportunity. Now I form the map as ...
1
vote
2answers
399 views

Cross-Object SOQL Query

I have a set of custom fields on my Accounts object that depict weather an Account is approved for business with our company. The Approved Date is added via an Approval Process, and Account Status is ...
2
votes
1answer
2k views

How can we find out the deleted record in After delete trigger?

I am writing a trigger to handle after insert,after update and after delete events. I am using trigger.old for after delete.But, how to differentiate the deleted record from the rest of the records of ...
1
vote
1answer
5k views

Trigger to update field values from another object

I got this scenario where there's two object say A and B, both of them having a field called BCode and Code . Now, if the values match then another field called X in A has to be populated with the ...
0
votes
2answers
96 views

can we avoid 2nd for loop

I have written this trigger in this can we avoid the second for loop using map. Trigger Sum on Contact(after insert, after update, after delete, after undelete) { Set<Id> accountIdSet = new ...
0
votes
2answers
286 views

Delete Record and its attachment Trigger is not working

trigger MyDocumentTgr on MyDocument__c (after delete) { private List<MyDocument__c> mdObjLst {get; set;} private List<Attachment> attObjLst {get; set;} set<ID> mdId = new ...
0
votes
1answer
27 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 ...
2
votes
1answer
125 views

Getting 101 SOQL error when updating bulk records through data loader

I have a trigger which updates the total amount of child record values into parent record fields. It is working fine when I do the single records insertion. I have 50000 child records which are ...
2
votes
1answer
1k views

Trigger After Insert Error : Record is read-only

still learning the apex ropes I've created a trigger which should create a contact after a custom object (School_bookings__c) record is created. My code is as follows: trigger CreateSchoolContact on ...
0
votes
1answer
629 views

Trigger creating duplicate records

I have written some code which create tasks whenever I create a new staff record based on some conditions. Trigger: trigger triggerTaskImplemetationonJob on Staff__c (before insert, before update) { ...
1
vote
1answer
158 views

I am receiving a “Variable does not exist: currentItem.Item_Family_Picklist__c” Error

I am receiving a "Variable does not exist: currentItem.Item_Family_Picklist__c" Error on my below trigger. I have verified the api name of the field and the correct object etc. the field exist. ...
2
votes
2answers
380 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
308 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
1answer
405 views

Getting System.ListException: Duplicate id in list:

I am getting "System.ListException: Duplicate id in list: " in After trigger.How to prevent this.I am trying to update the same record after callout in after trigger.Below is my piece of code: List&...
0
votes
2answers
813 views

Unexpected token trigger

I keep getting Error: Compile Error: unexpected token: 'trigger' at line 1 column 0 with this simple trigger trigger CreateWorkRecordsX on Staff_Week_Plan_Creator__c (after insert) { ...
0
votes
1answer
2k views

Apex Trigger on Opportunity Contact Role to assign primary to first contact on list

I designed a trigger to automatically Create Opportunity Contact Roles. Our organization is using an app called FastForms which creates an account, contact and opportunity. An issue we have with our ...
1
vote
1answer
111 views

how to know Orderitem trigger is triggerred by order trigger

some fields on orderitem can only be changed when the order is changed, so I need orderitem trigger to know if it's triggered by order trigger. how can I do this? Thanks
2
votes
2answers
132 views

Record is Read Only on After Insert Method

I wrote a method that works when it is before insert in my trigger handler. A problem I encountered is that the after insert method that already existed failed to run. I cannot figure out why it does ...
0
votes
1answer
66 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
34 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 ...
5
votes
1answer
956 views

Is it possible to write Trigger for Before & After DML?

I'm wondering if I can write the trigger on Case, that works before and after DML in one file? I have two triggers on Case - first with method working on records before insert, and second for records ...