Output array.string to Record in Flow Designer

DylanB
Tera Guru

Hi all, I'm thinking this should be a pretty simple solution but I'm not finding it. I'm using the Active Directory v2 spoke to get the list of groups that a user is a member of. That returns an array.string output. I'd like to take that list of groups and post it as a comment on a SCTASK. 

 

Dragging the data pill to the work notes comments results in the following. What am I doing wrong?

DylanB_0-1709057989820.png

 

1 ACCEPTED SOLUTION

No luck on that either. While looking at that look up action, I noticed that the PowerShell step outputs all the data that it looks up in a string format, including the membership.

DylanB_2-1709233773630.png

 

This gave me the idea to copy that Look Up User in AD action and remove all the Powershell attributes it looks up except for group membership, then store the Powershell output string as the membership output. That allows the membership to be displayed in string format to be used elsewhere in the flow. 

DylanB_4-1709233987188.png

 

It's not the prettiest output so I might go back and do some tidying up on it, but for now, it works well enough.

 

I'm not sure why other solutions weren't giving us the info we were looking for. I have to assume there is some bug with the AD spoke and this array. Additionally, this action should probably be OOB for this spoke. Being able to get full group membership for a user can be useful. 

 

I want to thank you all for responding. I learned a lot from this discussion and appreciate all the feedback!

View solution in original post

31 REPLIES 31

Sumanth16
Kilo Patron

Hi @DylanB ,

 

Please refer to below thread:

 

https://www.servicenow.com/community/developer-forum/how-to-iterate-an-array-string-in-the-flow-desi...

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

SanjivMeher
Kilo Patron
Kilo Patron

Do you also need to stringify it? something like javascript:JSON.stringify(your_output)


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

sasi_v
Tera Guru

Hi Dylan,

Comments is a journal field so dragging the data pill to the work notes comments won't work

You need to add extra script step to convert the array.string to string and populate same to comments field

If array.string stores string elements you can directly convert that to string using toString() method

If array.string consists of JSON objects then you need to use JSON.stringify option.

I think it's an array.string that consists of JSON objects but I can't be sure. 

I created a script step that used the toString() method but it just returned the value of the object.

DylanB_0-1709066367751.png

 

I've tried the JSON.stringify method also but I'm the same output just with quotes around it. 

 

This is the script action that I created.

 

 

DylanB_3-1709066552849.png