How to remove decimal from the email notification

Ballela Siva Te
Tera Contributor

Hi Team,

We are working on SLA notifications, below is the example of the notification that got triggered when an event is fired (75 % breach)

sub : SLA "XYZ- P3 resolution (2 days)" associated with INC0017809 has reached 75.02% of its allowed duration

 

Now we have to make the 75.o2 to 75 only

 

what is the easiest way  to achieve it ?

 

Regards

B Sva Teja

1 ACCEPTED SOLUTION

@Ballela Siva Te 

It comes from this OOTB Notification:

https://instanceName.service-now.com/nav_to.do?uri=sysevent_email_action.do?sys_id=9660628ed7a2220035ae23c7ce61039e%26sysparm_view=advanced

Steps to achieve

1) remove the subject from subject field

AnkurBawiskar_0-1745488450525.png

 

2) then update any of the existing email script and set the subject. I selected this "sla.salutation.event_parm1"

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

	var breachPercentage = parseInt(current.business_percentage);
	gs.info('ARB breachPercentage' + breachPercentage);
	var subject = "SLA " + current.sla.getDisplayValue() + " associated with " + current.task.number + "has reached " + breachPercentage + "%";

	email.setSubject(subject);

	var user = GlideUser.getUserByID(event.parm1);
	if (user.exists())
		template.print(gs.getMessage("Hello {0},", user.getDisplayName()));
	else
		template.print(gs.getMessage("Hello,"));

})(current, template, email, email_action, event);

Output: When I previewed the notification

The percentage 13.78% got converted to 13

AnkurBawiskar_1-1745488524356.png

 

AnkurBawiskar_2-1745488871011.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

@Ballela Siva Te 

which OOTB notification is being used here? share the name and screenshot

I already informed the logic

something like this to convert decimal to integer

var myIntegerValue = parseInt(decimalValue);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ballela Siva Te 

It comes from this OOTB Notification:

https://instanceName.service-now.com/nav_to.do?uri=sysevent_email_action.do?sys_id=9660628ed7a2220035ae23c7ce61039e%26sysparm_view=advanced

Steps to achieve

1) remove the subject from subject field

AnkurBawiskar_0-1745488450525.png

 

2) then update any of the existing email script and set the subject. I selected this "sla.salutation.event_parm1"

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

	var breachPercentage = parseInt(current.business_percentage);
	gs.info('ARB breachPercentage' + breachPercentage);
	var subject = "SLA " + current.sla.getDisplayValue() + " associated with " + current.task.number + "has reached " + breachPercentage + "%";

	email.setSubject(subject);

	var user = GlideUser.getUserByID(event.parm1);
	if (user.exists())
		template.print(gs.getMessage("Hello {0},", user.getDisplayName()));
	else
		template.print(gs.getMessage("Hello,"));

})(current, template, email, email_action, event);

Output: When I previewed the notification

The percentage 13.78% got converted to 13

AnkurBawiskar_1-1745488524356.png

 

AnkurBawiskar_2-1745488871011.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ballela Siva Te 

I believe I have answered your question.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks for the details explination