function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ian ClancyIan Clancy 

Is there a way to create a new child record for each selection in a multi-select picklist?

Is there a way to create a new child record for each selection in a multi-select picklist?
Best Answer chosen by Ian Clancy
Sanjay.GeorgeSanjay.George
Hi Ian,

You will need to write a trigger to do so. You may write a after insert trigger to process the multi-picklist values and create a new child record.

Sample code
Trigger CreateChild_AI_AU on <Object> (after insert , after update){


List<string> Temp;
for(<object> c: Trigger.New){
     for(string str: c.mulltipicklist__C.split(';'){
                           /// Create child and add them to a list

     }
}


}

Note: It will be better to use a map to avoid for in a for and you would also need to have a logic to handle removal of multi-picklist options.

All Answers

Sanjay.GeorgeSanjay.George
Hi Ian,

You will need to write a trigger to do so. You may write a after insert trigger to process the multi-picklist values and create a new child record.

Sample code
Trigger CreateChild_AI_AU on <Object> (after insert , after update){


List<string> Temp;
for(<object> c: Trigger.New){
     for(string str: c.mulltipicklist__C.split(';'){
                           /// Create child and add them to a list

     }
}


}

Note: It will be better to use a map to avoid for in a for and you would also need to have a logic to handle removal of multi-picklist options.
This was selected as the best answer
Ian ClancyIan Clancy
Thank you!