- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2015 12:28 PM
Could anyone share some thoughts on the best way to have a reference field (in my case 'assigned_to' updated with a null value?
When I run the background script below it seems to be working (Assigned To is blanked out) but am I not using 'NULL' as a string in that case?
Script:
updateAssignedToNull();
function updateAssignedToNull() {
var gr = new GlideRecord('incident');
gr.addQuery ('sys_id', 'b462031d2ba50a00345459efe8da15a1'); //sys id of my test incident
gr.query();
while (gr.next()) {
gs.print("Incident is: " + gr.number + " Assigned To before is: " + gr.assigned_to);
gr.assigned_to = 'NULL';
gs.print("Incident is: " + gr.number + " Assigned To after is: " + gr.assigned_to);
gr.update();
}
}
Output:
*** Script: Incident is: INC120559 Assigned To before is: a49664cec0cda080242596520e8ce6c2 //my user sys id, used to populate assigned_to on my test incident
*** Script: Incident is: INC120559 Assigned To after is: NULL
Thanks,
Marcelo Correia
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2015 12:38 PM
You should be setting the field value to an empty string:
gr.assigned_to = "";
By setting to NULL in quotes the system will see a value and display the reference icon on the field when displayed on a form, but the link will be dead since it doesn't match a reference sys id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2015 12:38 PM
You should be setting the field value to an empty string:
gr.assigned_to = "";
By setting to NULL in quotes the system will see a value and display the reference icon on the field when displayed on a form, but the link will be dead since it doesn't match a reference sys id.