• Documentation
  • Workato Blog
  • Product Blog
  • Return to Workato
  • Login
  • Automation Institute
  • Documentation
  • Community Forums
New Topic
Discussions Recipe Building Formula Mode Questions
S

Saul Macht

started a topic almost 5 years ago
Answered

Conditional Actions: Check if the field contains any of multiple words

Hi,


I would like to account for different words in my Message field. I want to know if it contains any of "United States", "USA", "US". How do I do this? I understand that I can divide them into multiple conditions, but I would prefer to keep it in a single formula.


Best Answer
P
Patricia Guevarra said almost 5 years ago

Hi Saul,


Thanks for reaching out! Please try the following formula:


Message.scan(/(United States)|(USA)|(US)/).present?

where Message is your data pill.


Let me explain this formula step by step.


1. The .scan formula checks if the field has any of the specified values and returns them as an array or as a list.

2. The .present? formula checks if the scan retrieved any matching values and will return "true" or "false" accordingly.

Answer

Patricia Guevarra

said almost 5 years ago

Hi Saul,


Thanks for reaching out! Please try the following formula:


Message.scan(/(United States)|(USA)|(US)/).present?

where Message is your data pill.


Let me explain this formula step by step.


1. The .scan formula checks if the field has any of the specified values and returns them as an array or as a list.

2. The .present? formula checks if the scan retrieved any matching values and will return "true" or "false" accordingly.

Amanda Wong

said over 4 years ago

Hi Saul, 


You can also use the .include? formula to help you evaluate that e.g. 


["US","USA","United States"].include?(Message)


Do note that only exact matches (case-sensitive) would evaluate to true.

Login to post a comment

Still can't find your solution?

Send us a ticket, we will try our best to assist you with your problem

Documentation
Developer's Library
Tutorials
eBooks
Product Hour
Product Blog
Workato Blog
Product updates
Customer Stories
© Workato 2022   Privacy   Terms   +1 (844) 469-6752
  • Documentation
  • Workato Blog
  • Product Blog
  • Solutions
  • Forums
  • Tickets
  • Log in
  • Return to Workato
Topic views count