We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to display Business time left as an info message when an incident is loaded

ellendulash
Tera Contributor

I want to show an info message when an incident is opened. Info message has to contain the Business time left of that particular incident.

1 ACCEPTED SOLUTION

HendrikO
ServiceNow Employee

Hi Sharan

 

You can create a display business rule as shown below:

- Table: Incident

- When: display

- Filter conditions: As you require. I added some state requirements in the example below.

 

HendrikOdendaa_0-1678110434769.png

 

With something similar to the below in the "Advanced" tab

(function executeRule(current, previous /*null when async*/) {

	var sla_gr = new GlideRecord('task_sla');
	sla_gr.task = current.sys_id;
	sla_gr.state = 'in_progress';
	sla_gr.query();
	
	if(sla_gr.next()) {
		gs.addInfoMessage('Business time left: ' + sla_gr.business_time_left.getDisplayValue());
	}

})(current, previous);

 

Let me know if this solves your issue, or if you need some clarifications.

View solution in original post

1 REPLY 1

HendrikO
ServiceNow Employee

Hi Sharan

 

You can create a display business rule as shown below:

- Table: Incident

- When: display

- Filter conditions: As you require. I added some state requirements in the example below.

 

HendrikOdendaa_0-1678110434769.png

 

With something similar to the below in the "Advanced" tab

(function executeRule(current, previous /*null when async*/) {

	var sla_gr = new GlideRecord('task_sla');
	sla_gr.task = current.sys_id;
	sla_gr.state = 'in_progress';
	sla_gr.query();
	
	if(sla_gr.next()) {
		gs.addInfoMessage('Business time left: ' + sla_gr.business_time_left.getDisplayValue());
	}

})(current, previous);

 

Let me know if this solves your issue, or if you need some clarifications.