How to highlight a field as a result of being changed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2014 10:07 AM
Hi all,
Does anyone have any insight as to how to cause the state field on an incident to take on a highlight (likely in the list view)?
To explain further, for our current setup, an incident can be set to a particular state (5, "Awaiting customer info"), which, when submitted will cause an email to be sent to the customer asking for more information. When this customer replies to the email, the state changes from 5 to 9 ("Work in Progress"). I would like to change the state field to have a colored background at this point.
A couple of approaches I took are as follows:
1. I tried to set up a field style where the value was set to
javascript: current.state.changesFrom(5) && current.state.changesTo(9)
2. I tried setting up an onChange() client script which read
if (oldValue == 5 && newValue == 9)
gs_form.getControl('state').style.backgroundColor = 'LimeGreen';
(this only worked when manually changing it from the ticket, it did NOT work with the inbound action)
3. I tried editing the inbound action with a line like
current.state.style.backgroundColor = 'LimeGreen';
or
current.getControl('state').style.backgroundColor = 'LimeGreen';
(these were undefined so it was posting an error)
So does anyone have any suggestions or point me in the right direction?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2014 07:43 AM
Only way I know is to set a variable on g_scratchpad with a display-business rule.
Next take a onLoad Client Script which checks g_scratchpad for the variable and its value and based on that you could trigger some code on the client script.
g_scratchpad<https://wiki.servicenow.com/index.php?title=Client_Script_Best_Practices#Example:_g_scratchpad>
Business Rule Process Flow<https://wiki.servicenow.com/index.php?title=Business_Rules#Business_Rule_Process_Flow>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2014 07:36 PM
Hi eican,
Yes you are correct. I use this in case of reading data on the form. But in this case, we need to get data like changesFrom and changesTo which we dont get in display business rules as it runs on display and not update.
If we could call a client script from an update/insert business rules then we can solve this problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-28-2014 06:58 AM
As far as I know the "previous" object is only available to the business rules which run after the record is send of for saving — I doubt an AJAX call would solve that.
My current call is that you need an additional field to store the previous value of the field as you need to highlight it also when the record is opened and not just changed. (You need to compare it to the last time it was saved and not to the state when it was opened by a user)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2014 02:57 PM
I think you can use 'oldValue' in a client script.