How to use dates in conditions

Table of Contents

Conditions and unaccepted data types

When working with conditions in our recipe, we may need to work with different data types such as date, string, array, number, etc. However, depending on the condition that you have chosen, the accepted data type defers. This may pose a problem if the condition (e.g. contains, equals to, etc.) you need in your recipe does not accept your required data type.

Let’s say you only want to process events with a start date in the year 2022. This would mean:

  • Trigger data: Start Date
  • Condition: Contains
  • Value: 2022

Here’s the problem – the trigger data is a date data type while the chosen condition contains only accepts array and string data types. However, I still want to check the date as a condition before moving forward with this automation. How can I troubleshoot this issue then?

date datatype unaccepted

“contains” condition only accepts Array and String data type

Back to basics: what are conditions?

Conditions are additional rules that you may add to control the flow of your recipe. This allows you to create more precise automations based on your business needs.

Let’s say you want to create a recipe that automatically escalates high priority support cases to the engineering team by connecting Salesforce to Jira – in this case, you may add a condition that limits only case types of Priority = High to be processed in your recipe.

In your recipe, you may include conditions in both triggers – trigger conditions – as well as actions – conditional actions.

trigger conditions conditional actions

Left, trigger conditions, right, conditional actions

 


Related:

How to use trigger conditions to filter events

How to use conditional actions in your recipe


Different conditions and their accepted data types

Below is a list of available conditions and the data types accepted.

  • contains – Array, String
  • starts with – String
  • ends with – String
  • doesn’t contain – Array, String
  • doesn’t start with – String
  • doesn’t end with – String
  • equals – Accepts all data type
  • does not equals – Accepts all data type
  • greater than – String, Date, Timestamp, Integer, Number, Boolean
  • less than – String, Date, Timestamp, Integer, Number, Boolean
  • is true – Boolean
  • is not true – Boolean
  • is present – Accepts all data type
  • is not present – Accepts all data type

Depending on the condition that you have chosen, the data type it supports defer. For example, the condition contains only accepts data types


Related: Understanding the data tree, data mapping, and data types


Using formula mode to convert your data type

Here’s how to troubleshoot the problem – use a formula to convert the current data type to your desired data type. Below, you’ll find a step-by-step tutorial on how to convert a date data type to a string data type.

In this example, we want to set up a trigger to filter for new or updated Salesforce cases that was last modified only in 2022. In summary:

  • Trigger data: Last Modified Date
  • Condition: contains
  • Value: 2022
trigger condition

Trigger condition that filter for cases that was last modified in 2022


Related: How to transform dates with formula mode


 Step 1: Change to formula mode

With your chosen datapill already selected, toggle to formula mode.

Toggle to formula mode

Step 2: Use the formula .to_s

To convert your date data type to a string data type, enter in the formula .to_s to the back of your chosen datapill.

convert data type with formula mode

Step 3: Save your recipe

Click save and test your recipe.

Congrats! You should see a successful test job.

successful test job

Successful test job after converting data type

More resources

Read the full documentation on the .to_s formula.

 

Was this post useful?

Get the best of Workato straight to your inbox.

Table of Contents