- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2019 02:27 PM
Are you passing ${workflow.scratchpad.group} to your powershell activity as an input?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2019 05:57 AM
Hello - Yes, I am passing it through as a powershell activity. I will attach a screenshot of that.
Just to note, I am successfully adding users to groups with a few other workflows. This is the only one that I need to go in and check on the user's region to determine the correct group to add them to. I think the issue might be with my 'If' statements for the Group variable, but I am not sure.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2019 07:33 AM
Hello -
If I comment out all those If statements and just declare the variable with the group name, it works. Can anyone help with the code on how I can dynamically set the variable? Thanks!!
var un = current.variable_pool.requested_for.user_name;
workflow.scratchpad.username = un;
// if (current.variable_pool.requested_for.location.u_region == '725') {
// var group = "Inventory Search West - BO";
// }
// else if (current.variable_pool.requested_for.location.u_region == '810') {
// var group = "Inventory Search TCI - BO";
// }
// else if (current.variable_pool.requested_for.location.u_region == '723') {
// var group = "Inventory Search Southwest - BO";
// }
// else if (current.variable_pool.requested_for.location.u_region == '724') {
// var group = "Inventory Search Southeast - BO";
// }
// else if (current.variable_pool.requested_for.location.u_region == '722') {
// var group = "Inventory Search Northeast - BO";
// }
// else if (current.variable_pool.requested_for.location.u_region == '721') {
// var group = "Inventory Search Midwest - BO";
// }
// else if (current.variable_pool.requested_for.location == '880') {
// var group = "Inventory Search Catalog - BO";
// }
var group = "Inventory Search Catalog - BO";
workflow.scratchpad.group = group;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2019 07:21 AM
I was able to get this sorted. Had to dot walk into the name field, also changed up the code a bit. Working now.
var un = current.variable_pool.requested_for.user_name;
workflow.scratchpad.username = un;
var reg = current.variables.requested_for.location.u_region.name;
var loc = current.variables.requested_for.location.name;
if (reg == '721') {
workflow.scratchpad.group = "Inventory Search Midwest - BO";
}
if (reg == '725') {
workflow.scratchpad.group = "Inventory Search West - BO";
}
if (reg == '810') {
workflow.scratchpad.group = "Inventory Search TCI - BO";
}
if (reg == '723') {
workflow.scratchpad.group = "Inventory Search Southwest - BO";
}
if (reg == '724') {
workflow.scratchpad.group = "Inventory Search Southeast - BO";
}
if (reg == '722') {
workflow.scratchpad.group = "Inventory Search Northeast - BO";
}
if (loc == '880') {
workflow.scratchpad.group = "Inventory Search Catalog - BO";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2019 02:46 PM
I developed below working add user to group activity in my instance.
You can set above parameters using below
workflow.scratchpad.ldap_server = gs.getProperty("glide.ldap.server.non_prod", "MID_SERVER_NAME");
workflow.scratchpad.user_name = buildsAMAccountName();
function buildsAMAccountName(){
var lastName = current.variables.last_name.toString().trim();
var firstName = current.variables.first_name.toString().trim();
var numLen = workflow.scratchpad.user_exists_count.toString().length;
var sAMAccountName = lastName.substring(0, maxLength - (numLen+1)) + firstName.substring(0, 1);
if(workflow.scratchpad.user_exists_count > 1){
sAMAccountName = sAMAccountName.substring(0, 7) + workflow.scratchpad.user_exists_count;
}
if(!userExists("user_name="+sAMAccountName.substring(0,8)))
return sAMAccountName.substring(0,8);
workflow.scratchpad.user_exists_count += 1;
return buildsAMAccountName();
}
workflow.scratchpad.group_names
workflow.scratchpad.group_names = [];
var restrictedGroups = gs.getProperty("glide.user.automation.restricted.groups");
var queryResults = new JSON().decode(data.get(18).output);
for(i=0;i<queryResults.length;i++){
var jsonObj = JSON.parse(new JSON().encode(queryResults[i]));
var groupList = jsonObj.memberof.split("CN=");
for(i=1; i<groupList.length; i++){
if((groupList[i].indexOf("OU=ddd") == -1) && (groupList[i].indexOf("OU=Prin") == -1) && (groupList[i].indexOf("OU=Admination") == -1) && (groupList[i].indexOf("OU=DynamGroups") == -1) && (groupList[i].indexOf("OU=Act Directory Management") == -1)){
var groupCN = groupList[i].split(",");
if(restrictedGroups.indexOf(groupCN[0]) == -1)
workflow.scratchpad.group_names.push(groupCN[0]);
}
}
}
if(workflow.scratchpad.group_names.length > 0){
workflow.scratchpad.group_names = workflow.scratchpad.group_names.toString();
activity.result = 'yes';
} else{
activity.result = 'no';
}
Regards,
Sachin