I'm a newbie here, and this is my first trigger.
This is a trigger which was given to me on here. It is in a sandbox in my organization. It is meant to create child records based upon a multi-value field in a parent record at the time the parent is saved. It doesn't seem to be creating the records upon being saved :
trigger AutoCreateSubs on Contract_Overview__c (after insert) {
List<Subs_Serviced_On_Contract__c> subs = new List<Subs_Serviced_On_Contract__c>();
//For each position processed by the trigger, add a new
//Subs_Serviced_On_Contract record for the specified Subsidiaries_On_Contract__c.
//Note that Trigger.New is a list of all the new positions
//that are being created.
for (Contract_Overview__c newContract : Trigger.New) {
if (newContract.Subsidiaries_On_Contract__c != null) {
// split out the multi-select picklist using the semicolon - or comma -delimiter
for(String subsoncontract: newContract.Subsidiaries_On_Contract__c.split(',')){
subs.add(new Subs_Serviced_On_Contract__c(
Name = newContract.Id,
Contract_Overview__c = newContract.Id,
Subsidiary_Name__c = (Id)subsoncontract,
Logo_Usage_Allowed__c = 'Yes'));
}
}
}
insert subs;
}
The trigger is at 100% code coverage and is Active. There is a value in the Subsidiaries_On_Contract_c field, so that wouldn't be preventing it from firing off.
Does anybody see anything wrong with this code which would prevent it from creating the records ? I'm not sure if it is error-ing out or not even firing off. Can somebody give me some direction on this ?
Thank you very much for your help.