Script to Initialize and add multiple AD groups

Kaz9
Giga Expert

Hello community!

      I am trying to get a script working that queries a variable on my form and adds those string values as ad groups to the username requested by the parent workflow.

Here is my script

var gr = new GlideRecord('x_prole_onboarding_onboarding');

gr.addQuery('u_string_105', current.variables.position); //job title field

gr.query();

var groupList = "";

var group = []; // this will be an array of objects

while (gr.next()) {

groupList = gr.u_sharepoint_groups;

group = groupList.split(',');

}

workflow.scratchpad.count = group.length; // the overall count available

workflow.scratchpad.groupList = groupList; // the list of AD groups

workflow.scratchpad.group = group;

workflow.scratchpad.counter = 0;   // our counter

workflow.scratchpad.host = '10.100.33.100';

workflow.scratchpad.user = current.variables.username;

Here is a picture of the Activity Properties to add user to group

addadgroups.PNG

here is a picture of the variable it is trying to pull information from

picture of group for array.PNG

I am getting over the right server IP and the right username but I cannot get it to use that list as AD groups to add in the activity. Any help would be great! please let me know if you need additional information. Thank you!

1 ACCEPTED SOLUTION

Kaz9
Giga Expert

workflow.PNG



the Run Script gets all of the information from my onboarding from as far as the groups go and adds them to an array which runs through the add user to group function. Here is the script for the Run Script.





var gr = new GlideRecord('x_prole_emp_onb_employee_onboarding'); //set to the name of the table where the form is located


gr.addQuery('u_job_title', current.variables.position.getDisplayValue()); //add a sort(query) value for the job title


gr.addQuery('u_list_location', current.variables.location); //add a sort (query) value for the location


gr.query(); //run query



var groupList = "";


var group = []; // this will be an array of objects



while (gr.next()) {


groupList = gr.u_distribution_lists + ',' + gr.u_printers + ',' + gr.u_sharepoint_groups + ',' + gr.u_proxy; //these are the variables on the form I want to get a list from. I ended up creating my variables all in lists.


group = groupList.split(',');


}



workflow.scratchpad.count = group.length; // the overall count available


workflow.scratchpad.groupList = groupList; // the list of AD groups


workflow.scratchpad.group = group;


workflow.scratchpad.counter = 0;   // our counter


workflow.scratchpad.host = '10.100.33.100';


workflow.scratchpad.user = current.variables.username;








This is my add user to ad group activity


addusertoadgroupactivity.PNG


View solution in original post

18 REPLIES 18

gtk
Mega Sage

we are facing same issue


please post if you found solution


Kaz9
Giga Expert

I did get this working I will post a solution here in a few minutes


Kaz9
Giga Expert

workflow.PNG



the Run Script gets all of the information from my onboarding from as far as the groups go and adds them to an array which runs through the add user to group function. Here is the script for the Run Script.





var gr = new GlideRecord('x_prole_emp_onb_employee_onboarding'); //set to the name of the table where the form is located


gr.addQuery('u_job_title', current.variables.position.getDisplayValue()); //add a sort(query) value for the job title


gr.addQuery('u_list_location', current.variables.location); //add a sort (query) value for the location


gr.query(); //run query



var groupList = "";


var group = []; // this will be an array of objects



while (gr.next()) {


groupList = gr.u_distribution_lists + ',' + gr.u_printers + ',' + gr.u_sharepoint_groups + ',' + gr.u_proxy; //these are the variables on the form I want to get a list from. I ended up creating my variables all in lists.


group = groupList.split(',');


}



workflow.scratchpad.count = group.length; // the overall count available


workflow.scratchpad.groupList = groupList; // the list of AD groups


workflow.scratchpad.group = group;


workflow.scratchpad.counter = 0;   // our counter


workflow.scratchpad.host = '10.100.33.100';


workflow.scratchpad.user = current.variables.username;








This is my add user to ad group activity


addusertoadgroupactivity.PNG


thanks for sharing



i have created catalog item


with variables (sys_name)


domain, group (lookup select box), u_requested_for



what should i input in domain controller, user name and group name i.e, format