You need to sign in to do that
Don't have an account?
Masechaba Maseli 8
Help with trigger to not create records already created
Hi all
I have a trigger that creates new child records from a parent. Parent is called Roll Out and the Child is called Cost Estimate. I would like that should it be refired that it checks for existing records before so as it avoid duplication. The duplicate check should be on the value and the the desitnation.
Any assistance with the duplication check and also ensuring that the code is bulkified will be appreciated.
I have a trigger that creates new child records from a parent. Parent is called Roll Out and the Child is called Cost Estimate. I would like that should it be refired that it checks for existing records before so as it avoid duplication. The duplicate check should be on the value and the the desitnation.
Any assistance with the duplication check and also ensuring that the code is bulkified will be appreciated.
rigger AutoCreateCostEstimates on Roll_Out__c (after insert, after update) { List<Cost_Estimate__c> interviewers = new List<Cost_Estimate__c>(); List<string> Temp; for (Roll_Out__c newPosition: Trigger.New) { if (newPosition.Destinations__c != null && newPosition.Create_Roll_Out__c == True){ // split out the multi-select picklist using the semicolon delimiter for(String destinationlist: newPosition.Destinations__c.split(';')){ interviewers.add(new Cost_Estimate__c( Client_Name__c = newPosition.Client_Name__c, Shipment_Value_in_USD__c = newPosition.Shipment_Value_in_USD__c, Destination__c = destinationlist, Roll_Out__c = newPosition.Id)); } } } insert interviewers; }
All Answers