We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to update list value in servicenow

Sathwik1
Tera Guru

How to update list field using background script, will set value will work here?

find_real_file.png

14 REPLIES 14

as sudhanshu already pointed next()

 

var com = new GlideRecord('core_company');
com.addQuery('name','ACME Australia');
com.setLimit(1);
com.query();
while(com.next()){
com.u_type = "00aba08d3790200044e0bfc8bcbe5dfc";
com.update();
}

while(com.next())

{

}

good catch 🙂

Willem
Tera Sage

Oh I see you wanted it in a background script:

var valuesToSet = [];
var table = ''; //fill in the table
var sysID = ''; //fill in the sys id of the record you want to update
valuesToSet.push(current.assigned_to.toString());//example to add assigned to
valuesToSet = new ArrayUtil().unique(valuesToSet);

var gr = new GlideRecord(table);
if (gr.get(sysID)) {
    gr.u_test = valuesToSet.toString();
    gr.update();
}

I want to update watch list from scripted rest api. Can you help me with script. I am not getting how to update it in the list