Problem statement - If you have multiple phone fields on a single record and want to setup separate opt out fields for the same. And messages should not go out if the respective opt out field is marked as true.
- Go to Setup
- In the quick find/search box, type "object"
- Now select object
- Click on SMS History
- Now go to the "Validation Rules" section
- Click on New
- Write a Rule name
- Ensure that the "Active" checkbox is marked as True.
- Now add the following formula and replace the colored part (mentioned below)
- In the "Error Message" type true (you can add any value here, it will show a generic error while sending out SMS to opted out record)
AND( smagicinteract__Contact__r.SMS_Opt_Out_2_new__c , smagicinteract__Contact__r.MobilePhone = smagicinteract__PhoneNumber__c )
smagicinteract__Contact__r.SMS_Opt_Out_2_new__c = the opt out field . - (you need to replace this with the API name of your opt out field)
smagicinteract__Contact__r.MobilePhone = the related phone field . - (you need to replace this with the API name of your phone field)
Repeat the above steps as many times depending on the total number of phone and opt out fields you require.