You need to sign in to do that
Don't have an account?
devloper sfdc
how to count items and how to get item of Multi selected picklist using trigger
Hello friend
I need to count Multi select picklist selected items and how to read those item using trigger.
for count i have create formula filed that working fine, but i dont want to use formula filed.
my objective if we selected two item in a list then two case created with subject name and subject name is item value .
trigger onandoffboardingticket on Case (before insert) {
List<SelectOption> objNames = new List<SelectOption>();
List<Case>newCace=new List<Case>();
List<String> recordType=new List<String>{'zCampusHelp_Internal'};
for(case c :trigger.new)
{
for(Integer i=1;i<=c.Count__c;i++)
{
Case cas=new case();
cas.AccountId=c.AccountId;
cas.Subject=c.Subject;
cas.Onboarding_Offboarding_Employee__c=c.Onboarding_Offboarding_Employee__c;
cas.Status=c.Status;
cas.ContactId=c.ContactId;
cas.Internal_Category__c=c.Internal_Category__c;
cas.Internal_Type__c=c.Internal_Type__c;
cas.Internal_Item__c=c.Internal_Item__c;
newcace.add(cas);
}
}
insert newcace;
}
I need to count Multi select picklist selected items and how to read those item using trigger.
for count i have create formula filed that working fine, but i dont want to use formula filed.
my objective if we selected two item in a list then two case created with subject name and subject name is item value .
trigger onandoffboardingticket on Case (before insert) {
List<SelectOption> objNames = new List<SelectOption>();
List<Case>newCace=new List<Case>();
List<String> recordType=new List<String>{'zCampusHelp_Internal'};
for(case c :trigger.new)
{
for(Integer i=1;i<=c.Count__c;i++)
{
Case cas=new case();
cas.AccountId=c.AccountId;
cas.Subject=c.Subject;
cas.Onboarding_Offboarding_Employee__c=c.Onboarding_Offboarding_Employee__c;
cas.Status=c.Status;
cas.ContactId=c.ContactId;
cas.Internal_Category__c=c.Internal_Category__c;
cas.Internal_Type__c=c.Internal_Type__c;
cas.Internal_Item__c=c.Internal_Item__c;
newcace.add(cas);
}
}
insert newcace;
}
You can simply retrive the multiselect picklist in a string and then split that string by ";". This should help you
for(Case c : trigger.new){
string pl = c.yourpicklistfield;
if(!string.isBlank(pl)){
list<string> pls = pl.split(';');
for(string str : pls){
your new case record
}
}
}
All Answers
You can simply retrive the multiselect picklist in a string and then split that string by ";". This should help you
for(Case c : trigger.new){
string pl = c.yourpicklistfield;
if(!string.isBlank(pl)){
list<string> pls = pl.split(';');
for(string str : pls){
your new case record
}
}
}
picklist