• DOCUMENTATION
  • WORKATO BLOG
  • PRODUCT BLOG
  • Return to Workato
  • Log in
  • ☰
  • Solutions Articles
  • Forums/Discussions
  • Submitted Tickets
Solution home Formula Mode Tips & Tricks Text Manipulation Formulas

How to use the where function

Created by: Nivedita Rajendiran

Modified on: Thu, Aug 29, 2019 at 5:48 AM

The where function can be used in combination with other functions (such as pluck) in order to filter information from a List (a type of Array). Since the where function returns an Array (the filtered List), any added function must be able to work with Arrays. The where function is useful when a step in your recipe (e.g. a search action) outputs a List containing many objects. For example, the image below shows the step output for a search accounts action. Here, a List of Account objects is returned containing all of the fields displayed under it (Name, Sub account, etc.) for each Account object. List fields are always marked with the  symbol.

When you have a List, you can work with it in many ways. For example, you may use the pluck function to extract the values of certain fields from each object within the List. However, in some cases you may want to narrow down the objects you want to work with before applying such a function. You can do this using the where function.

Finding the API Name: 

Just as with the pluck function, you will need to find the correct API name for a field to use as a filter. The names displayed for the pills in the step output are not always the correct name to use, especially when the name contains more than one word. Typically, you can get the API name for multiple word fields by removing the spaces and capitalizing each word. For example, a field named "Account type" will typically have the API name "AccountType". However, this is not always the case. To be sure, there are two places you can locate the API name for the field you want.

The first place you can find the API names for a field is the recipe output from a completed job. For example to find names for Account fields, you can look at successful output for any triggers or actions related to Accounts. You can also create a test recipe and search for an Account that you know exists. Here is the recipe job output for the search accounts action that lists all of the fields available by API name:

Screen Shot 2016-08-15 at 1.03.47 PM.png

The other place you can find the API names for a field is the actual API for the application you are using. Many APIs will publish the fields available for each object. However, not all APIs are easy to navigate so this method may take some more time and effort.

Using the Where Function:

Once you know the API names for the fields you want, you can write your formula. The format for the where function is as follows: [List Data Pill].where('APIname': 'filterValue'), simply separate them with a comma: [List Data Pill].where('APIname1': 'filterValue1', 'APIname2': 'filterValue2', 'APIname3': 'filterValue3'). Now you can add the main function you want to use to the end of the where formula. You can add on any formula that works with an Array. The combined formula will return whatever the last formula applied returns. Here is an example using the pluck function:

Remember that the pluck function will return an array object, so you will typically need to add on another formula such as to_s that converts an Array to a String.

N
Nivedita is the author of this solution article.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

Related Articles

    Still can't find your solution?

    Visit our forums to search for answers, or post your own questions.

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