I'm running a background script to update the old records of a sys_id requested_for column to the custom column u_opened_for and it's returning this message when I run the script and it just updates some records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2022 04:27 PM

var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery('u_opened_for=NULL^ORDERBYu_opened_for')
gr.query();
while (gr.next()){
gr.u_opened_for = gr.variables.requested_for.getDisplayValue();
gr. setWorkflow ( false ) ;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2022 08:50 PM
Hi, without details of your configuration and the value in the error message I would guess the issue is that 'u_opened_for' is a reference to the sys_user table and your variable is not a unique sys_id for a sys_user record?
You should be able to add a lookup of 'sys_user' based on your variable content (assuming it's unique).
Perhaps something like
while (gr.next()){
var userCheck = new GlideRecord('sys_user');
//guessing the variable display value is a name?
if(userCheck.get('name', gr.variables.requested_for.getDisplayValue())) {
gr.u_opened_for = userCheck.sys_id;
gr. setWorkflow(false);
gr.update();
} else {
gs.info("No match found for " + gr.variables.requested_for.getDisplayValue());
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2022 09:44 PM
Hi 123,
It seems your u_opened_by is a reference field for sys_user table.
When you are passing gr.u_opened_for = gr.variables.requested_for.getDisplayValue();
This wont work. For this to work, you will have to pass sys_id.
If you want the display value to be displayed then maybe try the following code:
var gr = new GlideRecord('sc_req_item'); gr.addEncodedQuery('u_opened_for=NULL^ORDERBYu_opened_for');
gr.query();
while (gr.next())
{
gr.u_opened_for.set.setDisplayValue(gr.variables.requested_for.getDisplayValue());
gr.setWorkflow(false);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 02:34 AM

I ran this script, but it didn't return any information even though I gave gs.print
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2022 04:58 AM