Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Sharan Ellendul
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

Hendrik Odendaa
ServiceNow Employee
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

Hendrik Odendaa
ServiceNow Employee
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.