Background script for updating multiple records in user table.
This content was last updated in 2022. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2022 03:08 AM
Hi,
I need a background script that will basically update a particular field in the user record after querying from sys_user_grmember table.
requirement: I need to check in the sys_user_grmember table by querying if group is active, group.company is abc and group is active and user.project is xyz
when i get all the lists from here , i need to update the 'designation' field(this field is present in user record in user table) of these users listed and update to a sys id .
How to write a sanitized background script for this .
Thanks!1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2022 03:37 AM
Hello,
var gr= new GlideRecord('sys_user_grmember');
gr.addEncodedQuery('Add your encoded query here');
gr.query();
while(gr.next()){
var gr1= new GlideRecord('sys_user');
gr.1addQuery(''sys_id',gr.user');
gr1.query();
if(gr1.next())
{
gr1.designation='sys_id you want to enter';
gr1.update();
}
}
Hope this helps. Please mark the answer as correct/helpful based on impact.