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

Ankur Bawiskar
Tera Patron
Tera Patron

@Ballela Siva Te 

if that's the OOTB email then you will have to use email script and convert that decimal to integer value and then print using template.print()

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
Tera Contributor

@Ankur Bawiskar 

Will it work in the subject of the mail ?

@Ballela Siva Te 

using email script you can set the subject as well

// ensure you convert decimal to integer before setting the subject.
var str = 'Your subject';
email.setSubject(str);

Mail script API 

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

@Ankur Bawiskar  Can you please elaborate