- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 08:28 AM
Hi,
We currently have a automated request to add users to groups. The process is you select the group and the user via the form. When submitted a approval will be sent to the group manager. Once approved the user will be added to the group. This has been working for sometime now but it has failed.
I think it is because the workflow has to impersonate a account with additional access like a admin. But it has worked in the past.
This is the code we are using.
var group = current.variables.add_group;
var user = current.variables.add_member.toString();
var array = user.split(",");
var adminUser = gs.getProperty('qbe.admin_account');
var originalUser = gs.getSession().impersonate(adminUser); // elevate priviledges to add roles
//gs.addInfoMessage("Selected users are:" + ' ' + user);
for (var i = 0; i < array.length; i++) {
var gr_member = new GlideRecord('sys_user_grmember');
gr_member.initialize();
gr_member.group = group;
gr_member.user = array[i].toString();
gr_member.insert();
}
gs.getSession().impersonate(originalUser); // return to original session
If anyone know why this would be please let me know or if there is a better way to do this.
Many thanks
Clinton
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2022 02:24 AM
The fix for this was to add a Timer action to the workflow before my script runs. The activity is then added to the event log which runs as the System, which has all the access needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2022 02:24 AM
The fix for this was to add a Timer action to the workflow before my script runs. The activity is then added to the event log which runs as the System, which has all the access needed.