How do you clear a reference fields value for current.fieldname?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2009 09:44 AM
How do you clear a reference fields value for current.fieldname? I found some docs to indicate that I should do the below but it does not work. Can anyone offer any help?
var clearValue;
current.u_affected_item = clearValue;
current.update();
Docs I am refering to.
http://wiki.service-now.com/index.php?title=Resetting_Reference_Fields
- Labels:
-
Orchestration (ITOM)
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2009 10:50 AM
Hmm...I just tried this on /demo and the empty quotes method worked just fine. The other two methods didn't work however.
current.u_affected_value = '';
current.update();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2009 11:10 AM
Did you do this when creating a new incident?
I just changed the code and it still is not clearing the field. I have tryed several ways and so far this is the ONLY way that it would work for me...? I just do not get it....
answer = current.insert();
if(current.u_affected_item){
var tci = new GlideRecord('task_ci');
tci.initialize();
tci.ci_item = current.u_affected_item;
tci.task = answer;
tci.insert();
var i = new GlideRecord('incident');
i.addQuery('sys_id', answer);
i.query();
while (i.next()) {
i.u_affected_item = '';
i.update();
}
}
gs.include('ActionUtils');
var au = new ActionUtils();
au.postInsert(current);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2009 08:41 PM
The "Resetting reference fields" example method is a client script, whereas this is a business rule:
http://wiki.service-now.com/index.php?title=Setting_a_GlideRecord_Variable_to_Null
current.u_affected_value = 'NULL';
current.update();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2009 04:10 AM
Ok, so I change the script to the below and it did not work either. For what ever reason I have to go get the glide record and set the value to null. I can not just do current.u_affected_item = "NULL"; it just does not work in this case. I still do not understand why but I have something that works. Thanks everyone for the input/help.
answer = current.insert();
if(current.u_affected_item){
var tci = new GlideRecord('task_ci');
tci.initialize();
tci.ci_item = current.u_affected_item;
tci.task = answer;
tci.insert();
// var i = new GlideRecord('incident');
// i.addQuery('sys_id', answer);
// i.query();
// while (i.next()) {
// i.u_affected_item = '';
// i.update();
// }
current.u_affected_item = "NULL";
current.update();
}
gs.include('ActionUtils');
var au = new ActionUtils();
au.postInsert(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2011 11:21 AM
nice