Skip to main content
Question

Dynamically output JSON string array contents


Forum|alt.badge.img

Hi all,

I have a workflow which contacts an API and obtains a json from it. The json has many fields, but I am interested specifically in the name field. Below is an incredibly trimmed down version of the json:

{
  "people_list": [
    {
      "name": "John Smith",
    },
    {
      "name": "Joe Bloggs",
    },
	{
      "name": "Jane Doe",
    },
   etc...
  ]
}

This response can return a json of different lengths depending on other options set in the Workflow, where sometimes there are more/fewer “people”.

As apart of this workflow, I’d like it to add a note containing the list of people that were returned. For example, if I had the above json returned it would add a note saying:

Names Found

John Smith

Joe Bloggs

Jane Doe

 

I understand I can access these individually using indexes (people_list.name[0], people_list.name[1], etc...), but I would like to do this automatically for each row it finds rather than addressing each index individually.

Is there a way to iterate through an array of strings in this way when adding notes to tickets via a Workflow? 

This is my first time trying to use the expression builder/liquid filters, so any help would be greatly appreciated


Thanks!

Did this topic help you find an answer to your question?

7 replies

Forum|alt.badge.img
  • Community Debut
  • 7 replies
  • September 3, 2024

Most of us are waiting for the looping in workflows to be released to see if this is possible.  At this point you will have to add the maximum number of indexes to that array in order to get all of the items.  


Forum|alt.badge.img
  • Apprentice
  • 1 reply
  • February 27, 2025
dino wrote:

Most of us are waiting for the looping in workflows to be released to see if this is possible.  At this point you will have to add the maximum number of indexes to that array in order to get all of the items.  


For clarity, are you just mentioning that it is a wanted feature among admins OR has it been mentioned somewhere on forums or a roadmap that this is upcoming?


Forum|alt.badge.img
  • Community Debut
  • 7 replies
  • February 27, 2025

I have had conversations with the product team and it is on the roadmap.  

Secondary, this is also in liquid filters but I have 35 individuals on my team and no one has been able to get that to work either.


Forum|alt.badge.img+2
  • Contributor
  • 23 replies
  • March 5, 2025

@NatDevine 

I had a similar issue you were trying to do except I needed to do this with data that was from within Freshservice itself such as a multiselect drop down to match from a custom object. 

 

I was able to get this to work using a liquid filter but it required the output to be an array of something that wasn’t an object in order to display the values. 

I my case I did it this way
 

Input

{% assign CustomObject = {{P8.root.records.records_object.data.product}} | split: "," %}

{% for item in CustomObject %}

{{ item | remove: "[" | remove: "]" | remove: '"' -}}

{% endfor %}

Output

All products

Pineapple

Pear

Apple

I had to split and assign the items from the object into an array in order for it to have the filter to work with it properly for some reason.

The remove filters are because the array it is working with spits out the square brackets and quotes no matter what I do.

 

Your data I see is an array of objects which I found much harder to grab data because it kept telling me Not given instead of a real error code. If I assigned the array of objects into a variable, it returned with nothing when I tried to access an item inside of it. When I try to echo out the assigned variable or the direct place holder in question, it doesn’t display anything. I am still working through several iderations of trying to see what it is not displaying anything. When I assign the array of P8.root.records.records_object.data then have it display it, it shows what is below but yet when you try to access it via through one of the array related filters, it poops itself. 

[{"bo_created_at":"2025-03-05T22:14:20.083Z","bo_created_by":{"id":31000000001,"value":"XXXXX YYYYYY "},"bo_display_id":3,"bo_updated_at":"2025-03-05T22:14:20.083Z","bo_updated_by":{"id":31000000001,"value":"XXXXX YYYYYY "},"description":"It is a pineapple","idtext":"Pineapple","product":"Pineapple"},{"bo_created_at":"2025-03-05T22:13:58.437Z","bo_created_by":{"id":31000000001,"value":"XXXXX YYYYYY "},"bo_display_id":2,"bo_updated_at":"2025-03-05T22:13:58.437Z","bo_updated_by":{"id":31000000001,"value":"XXXXX YYYYYY "},"description":"it is a Pear","idtext":"Pear","product":"Pear"},{"bo_created_at":"2025-03-05T22:13:47.740Z","bo_created_by":{"id":31000000001,"value":"XXXXX YYYYYY "},"bo_display_id":1,"bo_updated_at":"2025-03-05T22:13:47.740Z","bo_updated_by":{"id":31000000001,"value":"XXXXX YYYYYY "},"description":"It is an Apple","idtext":"Apple","product":"Apple"}]

 

If I make any progress I will let you know since this is import for us to show things that matched from a specific custom object based on the current permissions. it indeed would be better just to point to the array of objects instead of the specific value. 


Forum|alt.badge.img
  • Community Debut
  • 7 replies
  • March 6, 2025

@rawilkins 

I would be interested to see what node you put this in to accomplish the expected output.  I have had this request by a number of my consultants and we haven’t been able to work this out correctly.

 

Thank you,


Daniel Söderlund
Skilled Expert
Forum|alt.badge.img+14
dino wrote:

@rawilkins 

I would be interested to see what node you put this in to accomplish the expected output.  I have had this request by a number of my consultants and we haven’t been able to work this out correctly.

 

Thank you,

You can do that in add note, e-mail action or webrequest. 


Forum|alt.badge.img+2
  • Contributor
  • 23 replies
  • March 7, 2025
dino wrote:

@rawilkins 

I would be interested to see what node you put this in to accomplish the expected output.  I have had this request by a number of my consultants and we haven’t been able to work this out correctly.

 

Thank you,

Daniel is right. I used the Action Node then added as a note to test. 

In order to test pulling a list of items I first made a Custom Object table, then queried specific values from it so it will have more than one records.I am using display ids because that is what is returned from a multi select drop down when you check what was selected via API. 

You can use the following URI to query a specific Custom object based of it’s display IDs. 
/api/v2/objects/<ID of Custom Object>/records?query=bo_display_id%20%3A%20[3,2,1]

The Ids I am asking for are 1,2 and 3.

 

Then you parse the JSON results it gets back in a JSON Parser Node.

Then you can start using an action Note to write a note or to add to a paragraph field if you don’t want all the formatting.
 

By the way, I found a liquid filter that is supported that isn’t listed on the support liquid filter docs they normally point us to. 

If you ever want to see a filter that is being applied to a section such as have it written out, just place it in between{%raw%} and {%endraw%}. Super helpful for taking out filters that could be causing the issue you need to find out which one is causing the problem instead of deleting lines out. 

For example:

{%raw%}

{% assign CustomObject = {{P8.root.records.records_object.data.product}} | split: "," %}

{% for item in CustomObject %}

{{ item | remove: "[" | remove: "]" | remove: '"' -}}

{% endfor %}

{%endraw%}

 


Reply