Question

Get Array Length in Workflowautomator

  • 25 July 2023
  • 2 replies
  • 78 views

Hi, 

I want to monitor all of my Assets which are in stock.

So I created ah Workflow Automator which starts when a service request is raised, then I get all Assets with a GET request with a Filter in the URL. After that I use a JSON Parser to get the Array length. When the length is lower than for example 5 it should send an e-mail to the responsible person.
The problem is that I get “true” back form the JSON-Parser.

I hope you can help me.

 


2 replies

Userlevel 7
Badge +13

Hi, 

I want to monitor all of my Assets which are in stock.

So I created ah Workflow Automator which starts when a service request is raised, then I get all Assets with a GET request with a Filter in the URL. After that I use a JSON Parser to get the Array length. When the length is lower than for example 5 it should send an e-mail to the responsible person.
The problem is that I get “true” back form the JSON-Parser.

I hope you can help me.

 

You could use $.assets[5:].id then condition the placeholder if it’s empty there are less then 5 left. 

In this case just to test it I hade a list of 30 assets. 29: showed me 1 30: gave me blank.  
Not tested it in a WFA just in the parser node. 

 

Badge

Hi Eder,

Hope so you’re doing fine, there is an issue with your Workflow Automator when trying to monitor your Assets in stock. The "true" response from the JSON Parser might indicate that the parsing process is returning a boolean value instead of the expected Array length. To troubleshoot this, please ensure that the JSON data received from the GET request is valid and contains the Array with the Assets. Double-check the JSON structure and confirm that the data is being fetched correctly. Additionally, review your JSON Parser configuration to ensure it's correctly extracting the Array length.

Hope so you’ll get some out of it!

Cheers,

Bryce June

Reply