Using Microsoft Active Directory v2 Spoke in Flow Designer

jmiskey
Kilo Sage

I am trying to use the "Microsoft Active Directory v2 Spoke" in Flow Designer to add/remove people from AD groups.  On my Catalog Item, I have a List Collector field where they can select all the groups that they want to be added to/removed from.  I have then built a Custom Action that loops through my List Collector, and builds a string of all the AD Codes that they need to be added to, separated by commas.  So the output is a comma separated string.

 

If I go out to Flow Designer, go into the "Microsoft Active Directory v2 Spoke" and choose the "Add User to Groups" Action, there is an argument for Group Names that looks like this:

jmiskey_0-1709041122190.png

If I try to "drag-and-drop" the data pill from the output of my Custom Action, I get an error message that says "String is not allowed here".  I am not sure how to convert my output string from my Custom Action into an "array.string".  That doesn't even look like a valid data type I can use in my variables!

 

What do I have to do to get my output into an "array.string" field type so I can use it in this Group Names field?

 

Thanks

 

 

1 ACCEPTED SOLUTION

OK, I think I got it figured out now.

 

In the Script step part of my Custom Action, I need to set-up an output variable that is of "Array.String" type, i.e.

jmiskey_0-1709053180348.png

 

Then, in my Script portion, to first set up an array field in the script like so:

 

    var codes = [];

 

and then populate it with array values as I loop through my GlideRecord:

 

 

        while(gr.next()){
            codes.push(gr.field_name));
        }

 

 
Then, I need to populate my output variable at the end of the script like this:

 

    outputs.output_array = codes.toString();

 

 
If I do all of that, it will populate everything correctly, and it will allow me to drag-and-drop the output data pill from my Custom Action into the "Group Names" field, which requires an "Array.String" data type.
 
I tested it all, and it works!

View solution in original post

9 REPLIES 9

Configuring the same process as above, can you let me know the steps of the action you created to look up all the groups a user is a part of to be able to remove the user from those groups? 

 

Thank you

I was not looking up all the groups the person may be a part of.  I was looking up all the selections made on the form, and seeing if the person is a member of those particular groups.

So much for no-code functionality.

Hi @jmiskey 

Can you please share more detail so that I can use the same to solve the issue 

Here are the details of my Custom Action:

 

Inputs: 

jmiskey_0-1748344967544.png

 

Script step:

jmiskey_1-1748345014701.png

Script:

(function execute(inputs, outputs) {

    var str = '';
    var prevValue = '';
    var curValue = '';

    //loop through list collector (Glide Record)
    var gr2 = inputs.lc_variable;
    gr2.query();
    while(gr2.next()){
        //see if new Display Value different from previous one
        curValue = gr2.getDisplayValue();
        if(curValue!=prevValue){
            //add to running list
            str += curValue + ',';
        }
        //reset previous value
        prevValue = curValue;
    }

    //remove last comma from string
    str = str.substring(0, str.length-1);

    //set string to output
    outputs.output_string = str;

})(inputs, outputs);

jmiskey_2-1748345072663.png

 

Outputs:

jmiskey_3-1748345106008.png

 

jmiskey_4-1748345152319.png