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
paul.magpaul.mag 

Compare Picklist and MultiSelectPicklist values and update

Can anyone help me write a trigger that will update my Role_Level__c picklist with the value of strPortalRoleLevel__c picklist field if they do not match and if my checkbox intAutomaticallyUpdate__c is TRUE.

So

IF

intAutomaticallyUpdate__c = TRUE &&

Role_Level__c <> strPortalRoleLevel__c

 

Then

Update Role_Level__c with strPortalRoleLevel__c

 

Hopefully someone can help write this into an actual trigger, I also have some MSPL fields that will require the same / similar solution.

 

Thanks in advance

 

Paul

Suresh RaghuramSuresh Raghuram

Here i can suggest one thing since you are comparing the pick list value with multiselect picklist value, so 

 

get the mul pick value in to  a  string and then compare it with the picklist value

 

string str = Multipicklist value ; if it does not work type cast like this or     str = string.valueof(multi pick value);

 

then 

 string st = Role_Level__c

 str.Contains(string st)

intAutomaticallyUpdate__c = TRUE  && NOT(str.Contains(string st))

 

 

The above is just my idea 

 

If this solves your problem make this as a solution and give KUDOS Plz

Bhawani SharmaBhawani Sharma
you need to loop through the trigger.new records and set data based on your condition, like
for(Trigger.New) {
//Check for condition and set the value
}