Running Successive Pipes

Does anyone know if it’s possible to run pipes in succession?

For example: I have a name field (FIRST LAST). I want to replace the space with an underscore with replace(' ', '_') and then take the results and make the string lowercase with toLowerCase(). End result would be: first_last.

I think it should be possible. Have you tried using two rules, one to do the first step and the other to do the second step?

I haven’t tried but I’ll take a look.

So you definitely can run two pipes in a row and they will execute in order. I’m not sure if your equation will work because I haven’t use the search & replace pipe before so I’m not sure how to set it up. Here is an example I setup to test if the idea works:

  • I created 3 fields in the table (Name) (Pipe Result) & (Pipe Result 2) 1

  • I created a rule and used the text utility pipe to count the words in the name. In this case, the answer is 2 (first and last). and set the (Pipe Result) to the response Value

  • Then I made another rule and used the advanced math pipe to multiple (Pipe result) by 5 and set the (Pipe result 2) to the Response value

Worked like a charm.
3

3 Likes

@SuiteUpstairs is 100% right.

The only functions you can daisy chain are the text utilities.

For example, you can combine multiple functions together like so:

toUpperCase()->upperCaseFirst()->upperCamelize()->truncate(6)

As you can see here: https://docs.tadabase.io/categories/manual/article/text-pipes

2 Likes

Thank you both!

@SuiteUpstairs That was my thought as well to use a record field to hold temporary values. I’ll have to play around with it more but it seems one temp field doesn’t work; having the pipe read the record value, do the operation, then save back over the top of the original temp value. I’m not 100% sure on that, but I’ll experiment.

@moe That’s a very nice gem you posted! Text operations are something I can see doing a lot of so being able to chain those would be helpful. Thanks for posting that! I’ll be exploiting that feature for sure!