How to get number from array of numbers in workflow automator

Hi Team,

I’m creating a workflow automator with multiple web requests and parsers.

When I parse a web request response, even though the JSON output is in number, JSON path expressions show as an array of numbers

Preview value : [
  120001333444
]

I need to get requester detail using the above field value in https://abc.freshservice.com/api/v2/requesters/{{P1.root.requested_items.requested_items_object.custom_fields.who_will_act_in_the_position}}

As the field value is in an array and API is rejecting it. Can anyone suggest how to pass only number to the API ?

Thanks,
Kiran

Hello @Kiran would there ever be an instance where that field would contain more than one number? If not, then have you tried change the “Type” from Array of Numbers to just Number? The JSON parser allows you to cast a type to each of those properties.

Hope that helps. Take care.

Hi @Zach,
There will be always 1 number in that array.
I have tried the solution which you mentioned before and it always returns empty value

1 Like

Shoot! Sorry @Kiran, thought that might work. I will keep thinking on this.

Hello @Kiran,

  1. Agreeing with Zach - I’m assuming currently the field “Who will act in this position” is a multidropdown? if there is going to be only 1 person, why not change it to a single dropdown, in this case, it will be cast to number.

  2. We can get the array value in two ways:
    a. use this format {% assign value = {{P1.root.requested_items.requested_items_object.custom_fields.who_will_act_in_the_position}} %}{{value[1]}}
    b. Add a variable in the parser node itself. Attaching screenshots for reference


3 Likes

Thanks @Brindha_Rangarajan . It worked

1 Like

Been working as a Partner for almost 2 years deploying Freshservice and have asked support and others how to do this to no avail. The first example is using liquid filters and the JSON parser we’ve tried to use indexes in the placeholders, not JSON parser. JSON parser docs do not have anything about this.

JSON Parser Node : Freshservice

This shows the paths, but not that you need to add a variable to access the path and not placeholders.

1 Like

Hi @rasimm !

I used this Freshservice article to get the format - https://support.freshservice.com/en/support/solutions/articles/50000003382-powerful-placeholders-with-liquid-filters - example 5 is similar to splitting an array

1 Like

Hi Brindha,

We’ve used the liquid filters often, although we haven’t used any looping. It’s one item we hope will be available is the basic looping to process something like a multi-select dropdown content without creating linear flows for each index. The one I was surprised by was the context menu in the parser to Add a Variable. Any more tips and tricks you can share in the Workflow Automator (WFA)? :wink:

1 Like