Text in Formatter Extract Is Returning Every Occurrence Instead of Just 1
Can anybody help figure out why this is not simply returning the ID at the end of this sequence?
I’m trying to just extract the letters/numbers after the comma but it seems to grab all of the occurrences even with Match All set to No. There is a set of 4 values all comma separated, but I’m only trying to grab the last one.
Setup:
Current Output:
Page 1 / 1
Hi @JutstinD
Good question.
Instead try this: Formatter > Text > Split
Hi @Troy Tessalone thanks for the suggestion. I’m getting the same issue, it returns all 4 matches instead of just the last even though it’s set to last.
It is inside of a loop so maybe this is a bug with the loop function causing it?
I managed to find a workaround by using this python code snippet and Code By Zapier. Not sure why these other methods are returning every match even with the qualifiers.
fields = inputd'custom_fields']
id = fieldsdfields.rfind(',')+1:]
output = {'id':id}
@JutstinD
It may have to do with the format of the data.
Array with line items separated by commas
String with values separated by commas.
Good point @Troy Tessalone . It seems odd b/c it is splitting everything in both instances the way it should, just the return seems to be incorrect.
@JutstinD
We’d need to see screenshots with how you have each Formatter action configured in order to evaluate and advise.
FYI: There are also these Formatter options…
Formatter > Utilities > Text to Line Item
Formatter > Utilities > Line Item to Text
Here’s some screenshots of the split attempt. Maybe I’m missing something but this is what it’s giving me and when I try to use the output variable it contains all 4 pieces.
@JutstinD
FYI: When using a Code step, all input parameters are treated as strings. (e.g. array gets converted to a string, number gets converted to a string, etc.)
Here’s what’s likely happening with the Formatter > Text > Split as you had it configured…
The input value is an array, so the Formatter > Text > Split step is merely returning the array line items, since the input value is not a text string, thus the step is not actually finding any commas to split by due to the nature of the data (array vs text).
Example when I test with a string input separated by commas
Try this instead with the Formatter: (see screenshot note)
Formatter > Utilities > Line Items to Text (delimit with comma)
Example
There it is, @Troy Tessalone Thank you for all of the help on this! I didn’t understand why it was returning me a string of all of my custom fields to begin with, so it makes a lot more sense that it was actually an array.