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
Gwirizanani SinoiaGwirizanani Sinoia 

Compare Field value to a list of words

Hi all,
I was wondering if someone cloud help me figure this out. 
I have a custom object called "OrganisationRoleName__c"
With the following text field called "RoleName__c" 
Checkbox called ''Istrue__c"
I have a Static List of words ie 
  • Hamptom
  • Avenue
  • Road 
  • Community 
On the "OrganisationRoleName__c" object I have records with the following values:
  • New Hamport Place
  • People Avenue
  • Gregory Road
  • Developer Community
Scenario
If a record is created and RoleName__c name substring is contained in the Static List set strue__c= true.

Hope this makes sense.
Thanks in advance.




 
Sumit SFSumit SF
Hi Sionia,

If i understand your requirment  than below is your solution 

for(String str : Static List) {
    if(str.containsIgnoreCase(RoleName__c)){
        strue__c= true;
    }
}
Gwirizanani SinoiaGwirizanani Sinoia
@Sumit Pilaniya 2

Thanks for your response.
I think you misunderstood the requirement : the check should be the RoleName__c value (or subvalue ) needs to match Static List. For example if 
RoleName__c value = "Developer Community": then the Static List value will be = "Community" as RoleName__c has Community in the name. 
Hope this makes sense
Thanks again
Sumit SFSumit SF
for(String str : Static List) {
    if(RoleName__c.containsIgnoreCase(str)){
       RoleName__c = str;
        strue__c= true;
        break;
    }
}
Andrew GAndrew G
why not make your checkbox a formula checkbox, with a formula like:
 
IF(CONTAINS(RoleName__c, "Avenue", True,
IF(CONTAINS(RoleName__c, "Community", True,
IF(CONTAINS(RoleName__c, "Road", True,
IF(CONTAINS(RoleName__c, "Place", True,
IF(CONTAINS(RoleName__c, "Street", True,
False)))))

 
Wordsfind WordsfindWordsfind Wordsfind
Whose is the possessive shape of the pronoun who, at the same time as who’s is a contraction of the words who is or who has. However, many people still find whose and who’s in particular perplexing because, in English, an apostrophe followed by way of an s usually shows the possessive form of a word. who's vs whose (For example, a purse belonging to a lady is “the lady’s handbag.”) Not the case here, even though. So, to assist make clear further, watch this video that illustrates the variations and study greater below!