- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2017 11:24 AM
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
here is a picture of the variable it is trying to pull information from
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2017 06:59 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2017 07:26 AM
can you get me some more information? what is the process that you are using for that form? is it a catalog item that is filled out and then a workflow is generated? for the domain controller just put the IP address of whatever your active directory domain controller is. I think ours is going through a mid server though. can you send me some screen shots of what your form looks like? and what your workflow is?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2017 07:31 AM
we are trying to add/remove users from AD
in catalog item
requested for is user
group is to which group has to be add/remove
this is catlog item
in action : add/remove option
in domain : we have two domains
in AD group : list fo grops available
from checkout screen requsted for fiels is availabe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2018 03:50 PM
Out of curiosity, aren't you only applying the first group in your array to the users AD account? From the example above, in your "Add user to AD group" activity, you set the 'Group Name' field to: ${workflow.scratchpad.group[workflow.scratchpad.counter]}
And since you declared in your run script that workflow.scratchpad.counter = 0; Wouldn't this only apply the first group/object in your array to the users account?
Sorry to nitpick, I'm just trying to understand your code since I also need to apply multiple groups to an AD account. I'm having some issues though.
My post is here:
https://community.servicenow.com/community?id=community_question&sys_id=45aa0673db16db04fac7f4621f961941&anchor=answer_76cf963bdb1a5744852c7a9e0f961947
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2018 05:50 AM
What is your "If" conditions? in the Check Counter?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2018 06:20 AM
// This script needs to set answer to 'yes' or 'no' to indicate the state of the activity.
//
// For example,
//
// answer = ifScript();
//
// function ifScript() {
// if (condition is true) {
// return 'yes';
// }
// return 'no';
// }
answer = ifScript();
function ifScript() {
var check = 'no';
workflow.scratchpad.counter ++; // increment the counter
// check the counter and see if we need to go again or stop
if (workflow.scratchpad.counter < workflow.scratchpad.count) {
check = 'yes';
}
return check;
}