add values via a fix script to a glide_list type field

Wasd123
Tera Expert

Hello,

We have a table where I should modify several 100 records, so was thinking about a fix script. But whatever I try is not working and as I'm quite new to scripting, some help would be appreciated.

 

So on the table we have a field what is a glide_list type, and already has 1 or several values. Now I would need to add an extra value for all via a fix script in a way that the current values will stay in place.

 

If I try to query via a bancground script it shows correctly, but in realty when checking the record no data is being refreshed/updated.

 

 

 

 

 gs.print(gr.cmdb_model_category);
gr.cmdb_model_category = existing_value + ',' + '0be11f58c7432010f74c784c95c260b7'
gs.update();
gs.print(gr.cmdb_model_category);

 

 

 

here in the background script part is it first print the sys_id of the already existing value and the second prints the one what was there and the new as well, but somehow even if update condition is there is not being changed for the record.
 
what am I doing wrong?
1 ACCEPTED SOLUTION

Dale Hynes
Kilo Sage

Not sure if you picked up that "gs.update()" should be gr.update() !

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Wasd123 

do this

gs.print(gr.cmdb_model_category);
gr.cmdb_model_category = gr.cmdb_model_category.toString() + ',' + '0be11f58c7432010f74c784c95c260b7';
gs.update();
gs.print(gr.cmdb_model_category);

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

it is working oerfectly of there is onlt one category assigned, but if there are more then one like 2 or 3 assigned already, then it is deleting one and adding the new one.

So if category was 'Laptop PC' and 'Laptop' as well, it would remove the Laptop category and add the new one so at the end will have 'Laptop PC' and 'Mobile Device', but here I would need that the original 2 will stay and the new one would be added. so would have 3 category after the script. Could you help?

@Wasd123 

Please share the entire script as it's difficult to get the full context

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Dale Hynes
Kilo Sage

Not sure if you picked up that "gs.update()" should be gr.update() !