Change the text colour of Incident number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2015 01:42 PM
When the SLA is about to expire for a particular P1 incident, the colour of the Incident number text will change.
This is only for tickets where the SLA is ticking, not for pending status incidents.
Example:
3 hours SLA left: Orange
2 hours SLA left: Yellow
1 hour SLA left: Red
Would anyone like to give a hint on this? I tried writing a Script Include and then changed the Field Styles but it didn't work.
Below is the example which I took from the Community itself:
var CheckSLAState = Class.create();
CheckSLAState.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isSLAInProgress : function(incidentSysID) {
var checkSLA = new GlideRecord("task_sla");
checkSLA.addQuery("sla", 'cce4464f0f4f4600db7e715ce1050ed0');
checkSLA.addQuery("task", incidentSysID);
checkSLA.addQuery("stage", 'in_progress');
checkSLA.query();
if (checkSLA.next()) {
return true;
}
return false;
}
});
-----------------------------------------------
Field Style: javascript: var checkValue = (new CheckSLAState().isSLAInProgress(current.sys_id)); checkValue == true;
Thanks for any help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2015 02:46 PM
Your include is fine; however your field style value should be changed to the following:
javascript: new CheckSLAState().isSLAInProgress(current.sys_id)
In my test, I did this with the "background-color: orange" style text and it displayed the orange indicator in a list and did a "text-decoration: line-through" displaying a strike through; however I haven't been able to ever get the text color to change or to get the background color on the form view to work correctly (in the later releases).
The field style shows the proper display though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2015 03:05 PM
Looks like the only way I can tell to get the actual text to change color is through the UI using a client script. If you look at the default client script for "Highlight VIP Caller" on the incident table, it provides the method that they used to change the text from black to red on a caller that has VIP==true on their user record.
/sys_script_client.do?sys_id=8f0b3ee00a0a0b5700e75f4aaabe4953
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2015 11:44 AM
Thanks Mike. I tried with the first solution but even that is not working. The second one may be executable but I do not think that it will suffice my purpose. Suppose an SLA is attached to my incident which is of Priority 1 and the expiry time of the SLA is 4 hours. So, when 3 hours will be left, the text colour of the incident in the list layout will be Orange, when 2 hours will be left, the colour should change to Yellow and when one hour is left, the colour should change to Red. Do you have any idea of this? I am trying through Business Rules, but of no avail. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2015 12:29 PM
If you are wanting a time function, that you can use the time_left field in your query, or use the dateDiff function to get the difference of start and planned end. You will want three field style records with the conditions calling each function result.
javascript: new CheckSLAState().threeHrsRemain(current.sys_id)
javascript: new CheckSLAState().twoHrsRemain(current.sys_id)
javascript: new CheckSLAState().oneHrsRemain(current.sys_id)
var CheckSLAState = Class.create();
CheckSLAState.prototype = Object.extendsObject(AbstractAjaxProcessor, {
threeHrsRemain : function(incidentSysID) {
var checkSLA = new GlideRecord("task_sla");
checkSLA.addQuery("sla", 'cce4464f0f4f4600db7e715ce1050ed0');
checkSLA.addQuery("task", incidentSysID);
checkSLA.addQuery("stage", 'in_progress');
//Add a query for time_left here
checkSLA.query();
if (checkSLA.next()) {
return true;
}
return false;
},
twoHrsRemain : function(incidentSysID) {
var checkSLA = new GlideRecord("task_sla");
checkSLA.addQuery("sla", 'cce4464f0f4f4600db7e715ce1050ed0');
checkSLA.addQuery("task", incidentSysID);
checkSLA.addQuery("stage", 'in_progress');
//Add a query for time_left here
checkSLA.query();
if (checkSLA.next()) {
return true;
}
return false;
},
oneHrsRemain : function(incidentSysID) {
var checkSLA = new GlideRecord("task_sla");
checkSLA.addQuery("sla", 'cce4464f0f4f4600db7e715ce1050ed0');
checkSLA.addQuery("task", incidentSysID);
checkSLA.addQuery("stage", 'in_progress');
//Add a query for time_left here
checkSLA.query();
if (checkSLA.next()) {
return true;
}
return false;
},
});