I created one custom object Booking and in this i created one custom field name which is a multi picklist.Cars is one more custom object.If i select the multi picklist in Booking it has to create the record type in cars.
Example :This is the multi picklist value
Maruthi-New
Alto-Old
According to above example i need to create the record type in Cars depending on only considering Maruthi or Alto.
For this i need to check before hyphen and then depending on Maruthi or Alto i hv to create record type.
How can this be done using apex code.Please help me in this.i have confusion regrading how to check value before hyphen.
If I select both value then it is seperated by semicolon like
Maruthi-New;Alto-Old
I tried seperating semicolon but i dont know how to seperate upto hyphen and assigned to one more field.
For this one i need to ckeck both i.e whether it is Maruthi or Alto and whether it is Old or New.
How can this be done using apex code except hard coding.If i hard code then the length of the programme is long.Please help me in this
String fieldValue = 'Maruthi-New;Alto-Old'; //Take this from field
List<String> listOption = fieldValue.split(';');
List<String> listStrFinal = new List<String>();
for(String option : listOption)
{
listStrFinal.add(option.split('-')[0]);
}
system.debug(' ****** listStrFinal '+ listStrFinal);// this will give you {'Maruthi' , 'Alto'}
String fieldValue = 'Maruthi-New;Alto-Old'; //Take this from field
List<String> listOption = fieldValue.split(';');
List<String> listStrFinal = new List<String>();
for(String option : listOption)
{
listStrFinal.add(option.split('-')[0]);
}
system.debug(' ****** listStrFinal '+ listStrFinal);// this will give you {'Maruthi' , 'Alto'}
Do this
I hope I understood you issue correctly.
All Answers
Do this
I hope I understood you issue correctly.
Thank you.It is working.