Server side scripting portal widget snow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 11:46 PM - edited 11-08-2022 11:57 PM
Hello All,
I have the following requirement:
1. Deactivate the user selected from list of records.
2. Also, delete all the relationship that the user has
3. Condition -> current logged in User should not deactivate him/herself
I am trying to do it via Server side scripting but for some reason I do not get it right, need help on the same
data.user = gs.getUserID();
if(input&&input.username)
{
var grUserdel = new GlideRecord('sys_user');
grUserdel.addQuery('sys_id',input.username);
grUserdel.query();
if(grUserdel.next())
{
if(data.user == input.username)
{
gs.addInfoMessage("Logged in User cannot deactivate themselves");
return false;
}
else
{
var userid =grUserdel.sys_id;
grUserdel.active="false";
gs.addInfoMessage("User " +grUserdel.name +" has been Deactivated");
var grUserrel1 = new GlideRecord('cmdb_rel_person');
grUserrel1.addQuery('user',userid);
grUserrel1.query();
while(grUserrel1.next())
{
grUserrel1.deleteMultiple();
}
}
grUserdel.update();
}
}
Experts please need your suggestion here
@Ankur Bawiskar @Saurav9 @Amit Gujarathi @Mark Roethof @AnubhavRitolia @Pavankumar_1 @Murthy Ch @asifnoor @Anurag Tripathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2022 11:57 PM
So what's not working? where are you facing challenge?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 12:02 AM
Thanks for the reply, I do not see the Info message appearing and validating on Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 01:17 AM
what debugging have you performed so far?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2022 01:02 AM
Hi @DB1
What value are you passing in 'input.username' value. Can you add log for it and tell what you are getting in this variable value?
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
