Can you change the style if new comments come in on a list of records?

sbungener
Kilo Contributor

Can you change the style if new comments come in on a list of records?

Say an incident is assigned to a assignee.
OOTB the notification is on that the assignee will receive an email.
We have turned this off because of the many emails. Instead we would like to have the Incident be highlighted or marked with a certain style.

Is that possible? I have been trying to do this by adding an new style, but I do not know how to do this, should be a kind of javascript saying. If the Comments changes then.....

Anyone can help?

7 REPLIES 7

PeterWiles
Kilo Sage

You can change field styles, i.e. make the "comments" go red if the last update wasn't the user.
This should give you a head start: https://wiki.servicenow.com/index.php?title=Defining_Field_Styles

Hopefully thats what you are looking for.


Well I had visited the wiki page before and there is where I learned how to do it, but how do I trigger the fact that as you said
You can change field styles, i.e. make the "comments" go red if the last update wasn't the user.

Because I cannot see where I can configure that, so I presume I need some javascript to do that, but I am not so familiar with Javascript.

Can anybody help me with that?

Or can you configure this without a piece of javascipt?


Creating a Javascript statement in the Value field on the Field Style record is the way to apply a field style based on changes to the record. You have access to the current values on the record via the "current" object. I tried a quick experiment using the GlideElement changes() method but this didn't yield very good results, perhaps because the Comments field is a Journal field, and perhaps because the changes() method isn't available for use in field style scripts. I think you'd need to do something like using a client script to set the value of a new true/false field to true when the Comments change, then use a Javascript statement similar to this:



javascript: current.u_comments_changed == 'true';


where u_comments_changed is the name of the custom field added to the form (it can be hidden via a UI Policy or client script so that it's not visible to your users). I'd also recommend an on-load client script to change the value of this field to false under the proper circumstances (such as when the form loads).

I'm sure there are other approaches you could use, but this one sprang to mind.


MKhan1
Giga Contributor

Field styling depends on a specific field. for example, you can mention that when the incident state is 'work in progress' style is 'yellow'