You need to sign in to do that
Don't have an account?
Phuc Nguyen 18
Create multiple child records from parent with different value
Hello All,
Was wondering if someone will help me with the best approach for adding multiple child records:
Parent is Project and finance is child. The Child records will mostly be the same exexpt for a text field that I will populate:
Any suggestions would be greatly appreciated.
Cheers,
P
Was wondering if someone will help me with the best approach for adding multiple child records:
Parent is Project and finance is child. The Child records will mostly be the same exexpt for a text field that I will populate:
List<Finance__c> finline = new List<Finance__c>(); if(trigger.isInsert){ for (SObject so : Trigger.New) { Project__c newP = (Project__c) so; if (newP.ProjectChild__c != null ) { Finance__c newF = new Finance__c(); newF.Subject = newP.ProjectSubject__c; newF.description__c = 'Custom text for finance record'; finline .add(newF); newF.Subject = newP.ProjectSubject__c; newF.description__c = 'Another Custom text for finance record'; finline .add(newF); } } }Was wondering if there is a better way to perform this action. There will be 5-6 child records. Also, I will a different child record that will be created off the same parent record and there may be 3-4 records for this custom object.
Any suggestions would be greatly appreciated.
Cheers,
P
Hi,
You can take references from the below code.
Thank YouThank you,
P