+ Start a Discussion

Profanity check

I have a multiselect picklist in my grandparent object.

I have a text field in my object.

Whenever user enters text into this text field ,and after saving i need to check whether my text contains the values defined in picklist

This is mainly for a profanity check .

what is the best way to do this?


Do like this


trigger ProfanityCheck on Object__c(after insert,after update){

Set<String> pkVals = new List<Set>();
for(Object__c obj : Trigger.new){
String selObj = 'Object__c';
Schema.DescribeFieldResult pkField = selObj.getDescribe().fields.getMap().get(obj.FatherParent__r.GrandParent__r.PicklistField__c).getDescribe();
List<Schema.PicklistEntry> pkValues = urlParamType .getPicklistValues();
for(Schema.PicklistEntry p : pkValues ){
//Write what you want to do if that condition satisfies


If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.


Or you can also write a validation rule to check if the text contains any of the picklist values.

Satish Kumar
Can you please write the exact formula how we do that.
A multipicklist where values are defined

and a text fields where i need to check whether any of the content contains any of these values in picklist
IF(Contains(SampleText__c,IF(INCLUDES( Parent__c.Profanity_Picklist__c ,"Xyz"),"Xyz","")),true,false) 


The values are case sensitive i believe.


If there are a lot of values in the picklist, its best to use a trigger as one of our members suggested.


Hope this helps. 


Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.