How do I blank a field from a Business Rule or Script Include..?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2012 10:04 PM
Hi all
I have been trying to create a Business Rule or a Script Include that is executed from a Reference Qual attribute on a reference field.
Besides returning the query this code should also set another (related) field to blank when-ever it is executed. The point with this is mainly to set that other field (also a reference field) to blank every time the user clicks on the magnifier on the reference field (this is a requirement from the users).
My problem is that I am having a problem finding the right syntax for setting the field to blank.
I have e.g. tried a simple expression like this one below, on both a Business Rule and Script Include:
current.u_location = '';
(the field that should be set to blank is called u_location and it is a reference field)
Besides that I have tried g_form.clearValue('u_location') and also constructions like this:
var uLocBlankVal; g_form.setValue('u_location', uLocBlankVal);
(the idea with above script is to set the field value to an undefined variable, as explained here: https://wiki.servicenow.com/index.php?title=Resetting_Reference_Fields)
None of these have so far set the u_location field to blank, however.
Is field blanking even possible from a Script Include or a Business Rule?
TIA
- Labels:
-
Orchestration (ITOM)
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2012 07:53 AM
i agree with the previous poster to acomplish something similiar i used an on change client script with the line
g_form.clearValue('v_server_patching');
and it worked fine... is there a reason it has to be a BR or a script include?
If i understand correctly a BR runes when it loads/updates the database.. so won't take affect till they try to save the record.. and a script include wouldn't run after it was loaded either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2012 10:18 AM
It sounds to me that you want to do this on client script. The idea will be when they make a change to a field then the other one gets clear out.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2012 10:23 AM
There was actually an onChange Client Script for the field and I was able to modify that to clear the other field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2013 08:03 AM
Hi! I have a question in regards to clearing a value. I've created a UI Policy to clear the contents of a field based on a condition. Works great, however if the condition is then reversed (i.e., state changes BACK to New), then the contents reappear. Is there a way to clear the contents and keep it that way even if the condition was reversed?
State changes to Complete
function onCondition() {
g_form.clearValue('u_sensitive_data');
}
State change back to New from Complete
The data reappears.