- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2016 05:09 AM
Hey Folks,
I'm trying to parse through text and get values to use within a script.
Since this is very confusing i'm asking to see if any of you scripting masters can do this, or point me in the correct direction.
We are automatically deactivating itil users after they haven't logged in within 30 days.
We are removing them from groups, and removing their email address from their account and putting it in a field on the user record "u_information"
The blub being put in this "Information" field is like so.
User removed from the following groups due to inactivation on 08-08-2016
Groups: Interfaces,Dept IT Analysts,Applications, Provisioning
Default Group: Provisioning
Email: jparker@test.com
What i'm looking to do is to create a UI Action to reactivate users who have been disabled.
So i want this UI Action to be a 1 click action, to set:
1. active = 'true'
2. locked_out = 'false'
3. get the email address from the information field and put it back in the email field.
4. get the default group and put it back in the default group reference field.
5. get the "Groups" and add the user back to all of the groups listed.
Does this seem possible?
Any help will be greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2016 07:55 AM
Here you go
var str = current.u_information;
var lineArr = str.split('\n');
var groupLine = '';
var defaultGroupLine = '';
var emailLine = '';
for (var i = 0; i < lineArr.length; i++) {
if (lineArr[i].indexOf('Groups:') == 0)
groupLine = lineArr[i];
if (lineArr[i].indexOf('Default Group:') == 0)
defaultGroupLine = lineArr[i];
if (lineArr[i].indexOf('Email:') == 0)
emailLine = lineArr[i];
}
current.active = true;
current.locked_out = false;
if (groupLine != '') {
var groupList = groupLine.split(':')[1].split(',');
for (var g = 0; g < groupList.length; g++) {
var grMember = new GlideRecord('sys_user_grmember');
grMember.newRecord();
grMember.user = current.sys_id;
grMember.group.setDisplayValue(groupList[g].trim());
grMember.insert();
}
}
if (defaultGroupLine != '') {
var defaultGroup = defaultGroupLine.split(':')[1];
current.u_default_group.setDisplayValue(defaultGroup.trim());
}
if (emailLine != '') {
var email = emailLine.split(':')[1];
current.email.setDisplayValue(email.trim());
}
current.update();
action.setRedirectURL(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2016 10:26 AM
Hi Steven,
Can you share the script for :
"So we have a script that after a user is deactivated, it clears the email, removes the default group, and removes them from all group membership.
that all works fine."
I have a similar requirement but i want to remove the groups only from the user accounts who have not logged into the system for more than 30 days..
Thanks,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2016 07:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2016 01:37 PM
