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

Could you please add logs and check where the script went wrong.

I'm not getting any system or flow errors or logs when running it, unfortunately.

After doing some more research, I adjusted the script to this:

(function execute(inputs, outputs) {
  var arr=[];
  var obj = inputs.array_string;
  for(i = 0; i < obj.length; i++){
    var str = JSON.stringify(obj[i]);
    var parsed = JSON.parse(str);
    arr.push(parsed);
  }
  outputs.output_string = arr.join(",");
})(inputs, outputs);

 

The lookup step is returning the array.string correctly.

DylanB_0-1709147982500.png

 

It appears the issue is when that object is passed to the next step. The runtime value does not appear to be the array.

 

Hi @DylanB ,

Problem is with 'Member Of'. Updated the script accordingly. Refer to below script

 var arr=[];

var mem="Member Of"

var obj=[{"Member Of":["test1,test2,test3"]},{"Member Of":["test4,test5,test6"]}] //pass your input here

for(i=0;i<obj.length;i++){
var str = JSON.stringify(obj[i]);
gs.info(str)  //remove this log , if this script is working
var parser = new JSONParser();
var parsed = parser.parse(str);
gs.info(parsed[mem]) //remove this log, if this script is working
arr.push(parsed[mem].toString());
}
gs.info(arr) //remove this log, if this script is working
var finalStr=arr.join(",")  //Map output here

 

Regards,

Sasikanth

If this solution was able to help you with your problem, please mark it as helpful.

Follow me on Linkendin

 

 

Hi @DylanB ,

Above approach has to work, doesn't it?

Hi @sasi_v, within the Script action itself, the script does correctly output the string. When moving the script action over to a flow and using it that way, it's returning just commas again. 

 

I think the issue may be related to how the array.string variable is passing from one step to the next. It wouldn't let me post this picture before but this is the initial runtime value that step 2 is receiving. 

2024-02-28 13_22_02-Window.png