cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Assembling a string with multiple Variables - String Interpolation

tshoemaker
Deputy Chef III
Deputy Chef III

Wondering if Workato has the concept of String Interpolation similar to C# where you can assemble multiple strings into one string.

For example, I have the need to create a text string that says:

"Your Part is: ABC123, Red Widget, and it will deliver on Feb 1 2022"

This is made up of three variables PartNum, PartDesc, and DelDate.

I know that I could use a formula such as:

"Your Part is: "+PartNum+", "+PartDesc+", and it will deliver on: "+DelDate

BUT.. in C# and other languages there is the concept of String Interpolation. The above could be written like this:

"Your Part is: {0}, {1}, and it will deliver on: {3}",PartNum, PartDesc, DelDate

Is this a thing in Workato Forumlas?

10 REPLIES 10

tshoemaker
Deputy Chef III
Deputy Chef III

ANSWER! Yes you can... RUBY does have the concept of String Interpolation (see http://ruby-for-beginners.rubymonstas.org/bonus/string_interpolation.html


To test this, i did the following in a string variable setting formula: (as seen in the attached image). The result was "My Name Is Tim Shoemaker and my email address is tshoemaker@epicor.com"

This makes the assembly of long text messages easier because you don't need all those quotes and plus signs.



Yes, that's also doable:) you can also add "present ? <true datapill> : <false data>" construct to handle nulls

vinny-sosa
Deputy Chef I
Deputy Chef I
The closest thing I have encountered to something similar is join or format on arrays. Still using functions. 

--

gabriel-sim
Workato employee
Workato employee

Hi Tim, string interpolation and string format are supported.




More examples: https://app.workato.com/recipes/2111405

This is useful when you need to apply formulas to the datapills before you form the string. Otherwise, Kirill Krivonos solution of dragging datapills to text mode would be ideal