- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I can use gr.setValue('parent', targetSysId); to update the parent field of a kb article to a specific KB, however, I can't use gr.setNullValue('parent'); to set the parent field to NULL, why?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @Lisa71 ,
The parent field is a reference field, and setNullValue() does NOT work on reference fields
ServiceNow is inconsistent here:
setNullValue() only reliably works on certain field types (string, numeric, date, etc.).
For reference fields, the platform may ignore setNullValue().
This is a known platform quirk — reference fields often need to be nulled using setValue() instead
gr.setValue('parent', '');
OR
gr.parent = '';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @Lisa71 ,
The parent field is a reference field, and setNullValue() does NOT work on reference fields
ServiceNow is inconsistent here:
setNullValue() only reliably works on certain field types (string, numeric, date, etc.).
For reference fields, the platform may ignore setNullValue().
This is a known platform quirk — reference fields often need to be nulled using setValue() instead
gr.setValue('parent', '');
OR
gr.parent = '';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
Thank you! This helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
Hi @Lisa71
To meet the requirement, please try the following script:
gr.setValue("parent", "");
OR
gr.setValue("parent", "NULL");
ServiceNow does not provide an out-of-the-box setNullValue() method on GlideRecord, so using an "NULL" or an empty string with setValue() is the correct approach to clear the field.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @Lisa71
As @Juhi Poddar , there is no method under GlideRecord as "setNullValue". I also looked into API documentation multiple times, couldn't find one.
You can follow this ServiceNow documentation to set the Null - https://www.servicenow.com/docs/bundle/xanadu-api-reference/page/script/server-scripting/reference/r...
