Using an Array.Object in a For Each loop, in a flow

ericgilmore
Tera Guru

ver. Vancouver

So I have this flow that calls a flow action from within a For Each (flow logic) and I can NOT access a value in the Array.Object.

 

The Array.Object has the structure:
Fix Versions (Array.Object)

   |- Fix Versions child0 (Object)

      |- name

The For Each structure:

[Look up a list of records from Problem]

For Each Item (Problems)

   |- Set Flow Variables [Release][Fix Versions.Fix Versions child0.name]

 

Problem is, inside the For Each, the data pill for FixVersions.FixVersionsChild0.name is greyed out. I'm not allowed to drag and drop into the Flow Variable field value.

 

When outside of the For Each loop I CAN drag and drop the value into a field.

 

What is this? Is it stated somewhere the you can't access part of an Array.Object's data if it's below a certain level in to flow, or object?

 

Why ServiceNow, why?

1 ACCEPTED SOLUTION

ericgilmore
Tera Guru

Here's the re-configuration that worked for me. First I'd like to thank @Chuck Tomasi for some insight about this issue found here: NOWCommunity Live Stream - Lessons Learned - Flow Designer Tips 1

 

First issue:
I was not receiving the entire JSON object from the Jira instance we were integrated with. I found that when I looked through the response body from Jira, there were fields/data NOT present in the JSON. Well as @Chuck Tomasi mentioned, it was being TRUNCATED by the system property setting in com.snc.process_flow.reporting.serialized.val_size_limit, after increasing the set value to 32768 I began receiving the complete JSON object from Jira.

 

Now I MUST CAUTION YOU the first time I made changes to the script step in my Flow action, I SAVED before I'd updated the script step Output Variables and the Outputs action output variables. Don't be me, be better. It wiped out all the configured Action Outputs that previously existed and I had to start again with a fresh copy of the flow action. DO NOT SAVE until you've made your changes to both sets of outputs. In fact I suggest you add the new variable to the Outputs > Action Output > variables, then Script step outputs,THEN SAVE. Then update the script step, Save, Publish, Test.

Now to continue...


Then to fix the original issue, I updated the flow action used by the main flow to explicitly assign the value I needed from the Array.Object to it's own output variable. This was done in one of the script steps by adding a line to a script step like so:

var result = JSON.parse(inputs.payload);
outputs.issue = res;
var release = res.fields.fixVersions[0].name;
~
~
~
outputs.issue.release = release;

 

And in the script step output variables...
> [Release][release][String]

And in the Outputs doing the same...

 > [Release][release][String]

After doing this I was able to then select Release from the data pill in the flow w/the For Each flow logic activity w/o issue.

View solution in original post

2 REPLIES 2

SanjivMeher
Kilo Patron
Kilo Patron

If Fix Versions is an array, did you try adding another For Each for Fix version and then try getting the child.name?

Would you be able to share a screenshot which would make it easier to understand?


Please mark this response as correct or helpful if it assisted you with your question.

ericgilmore
Tera Guru

Here's the re-configuration that worked for me. First I'd like to thank @Chuck Tomasi for some insight about this issue found here: NOWCommunity Live Stream - Lessons Learned - Flow Designer Tips 1

 

First issue:
I was not receiving the entire JSON object from the Jira instance we were integrated with. I found that when I looked through the response body from Jira, there were fields/data NOT present in the JSON. Well as @Chuck Tomasi mentioned, it was being TRUNCATED by the system property setting in com.snc.process_flow.reporting.serialized.val_size_limit, after increasing the set value to 32768 I began receiving the complete JSON object from Jira.

 

Now I MUST CAUTION YOU the first time I made changes to the script step in my Flow action, I SAVED before I'd updated the script step Output Variables and the Outputs action output variables. Don't be me, be better. It wiped out all the configured Action Outputs that previously existed and I had to start again with a fresh copy of the flow action. DO NOT SAVE until you've made your changes to both sets of outputs. In fact I suggest you add the new variable to the Outputs > Action Output > variables, then Script step outputs,THEN SAVE. Then update the script step, Save, Publish, Test.

Now to continue...


Then to fix the original issue, I updated the flow action used by the main flow to explicitly assign the value I needed from the Array.Object to it's own output variable. This was done in one of the script steps by adding a line to a script step like so:

var result = JSON.parse(inputs.payload);
outputs.issue = res;
var release = res.fields.fixVersions[0].name;
~
~
~
outputs.issue.release = release;

 

And in the script step output variables...
> [Release][release][String]

And in the Outputs doing the same...

 > [Release][release][String]

After doing this I was able to then select Release from the data pill in the flow w/the For Each flow logic activity w/o issue.