Newbie to salesforce and looking for a way to write a trigger that will create 11 line items for when a field is update. Object is credit request and when this is saved would like multiple credit lines to be added which is also an object. Below is a rough start, but looking for guidance. Picture attached showing what I would like to see after the request is saved and line items automatically created.
trigger TestCreditLinesAdd on Credit_Request__c(after insert){
List < Credit_Lines__c > creditlines = new List < Credit_Lines__c > ();
for (Credit_Request__c cr: trigger.new) {
creditlines.add(new Credit_Lines__c(.Quantity__c = 0.001));
}
insert creditlines;}
after update
either in place of or in addition toafter insert
.