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
streetstreet 

Trigger, Where to to check the multi select Picklist contains.

I have trigger where i need to check a Multi select picklist value if it contains Value Temporary then the value has to update by entering into If() Condition as shown below.

 

trigger Update_Candidate_TempLocation on Contact (before insert,before update)
{
for(Contact c:trigger.new)
{
if(c.Candidate_Position_Type_IDs_New__c=='temporary' && c.RecordTypeid=='012D0000000hW06')
{
c.Candidate_Temp_Location_New__c=c.MailingState ;
}

}

}

 

This is my code. How to look into it, if multi select picklist contains Temporary!!!

 

 


Best Answer chosen by Admin (Salesforce Developers) 
ClintLeeClintLee

There is a String method named contains() that you can use like this:

 

if( c.Candidate_Position_Type_IDs_New__c.contains( 'Temporary' ) ) {

 // add logic here

}

 

Here's a link to the String Methods - http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm

 

Hope that helps!

 

~ Clint

All Answers

ClintLeeClintLee

There is a String method named contains() that you can use like this:

 

if( c.Candidate_Position_Type_IDs_New__c.contains( 'Temporary' ) ) {

 // add logic here

}

 

Here's a link to the String Methods - http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_string.htm

 

Hope that helps!

 

~ Clint

This was selected as the best answer
streetstreet

Thanks for the reply.

 

I had no idea on contains in trigger.

Got it, its working now.

 

Thanks Clint.

srikanth gubbala 1srikanth gubbala 1
@clintlee Thanks it helped after longtime :)