Notification contains days count in decimal. Want to remove decimal part.

Evan2
Kilo Guru

Dear All,

 

We are triggering email notification after state is resolve of an incident. The sample notification is like below-

"Your incident INC0000001 has been resolved.The incident will automatically close in 5.0 days" 

Here it shows auto close day in decimal. I want to change it only to integer. Please help me.

 

Regards,

Nandan

1 ACCEPTED SOLUTION

dvp
Mega Sage
Mega Sage

Can you try this in email script and see if it works

 

(function runMailScript(current, template, email, email_action, event) {
template.print('<p><font size="5" color="#808080" face="helvetica">');
template.print(gs.getMessage('Your incident has been resolved.'));
template.print('</font></p>');
template.print('<p><font size="4" color="#808080" face="helvetica">');
template.print(gs.getMessage('The incident will automatically close '));
var days = parseInt(gs.getProperty("glide.ui.autoclose.time"));
var hours = days * 24;

if (days == 0)
template.print(gs.getMessage('now'));
else if (days <= 3) {
if(hours == 1)
template.print(gs.getMessage('in {0} hour', hours.toString()));
else
template.print(gs.getMessage('in {0} hours', hours.toString()));
}
else {
if(days == 1)
template.print(gs.getMessage('in {0} day', days.toString()));
else
template.print(gs.getMessage('in {0} days', days.toString()));
}
template.print('</font></p>');
})(current, template, email, email_action, event);

View solution in original post

16 REPLIES 16

Hi ,

I was earlier using the same but I am getting value in decimals. But I want only integer value.

 

Notification is showing like this:

Your incident has been resolved.The incident will automatically close in 5.0 days

 

Regards,

Nandan

Hi Kumar,

 

//change the code at line number 9 with below code

template.print('in ' + (hours + "").substring(0,(hours + "").indexOf("."));+ ' hour' + ((hours>1) ? 's' : '' ) );

//and also the code at line number 11 with below code

template.print('in ' + (days + "").substring(0,(days + "").indexOf("."));+ ' day' + ((days>1) ? 's' : '' ) );

 

let me know if that is working

Hi ,

 

I am getting error while changing the script.

PFB.

find_real_file.png

 

Nandan

dvp
Mega Sage
Mega Sage

Can you try this in email script and see if it works

 

(function runMailScript(current, template, email, email_action, event) {
template.print('<p><font size="5" color="#808080" face="helvetica">');
template.print(gs.getMessage('Your incident has been resolved.'));
template.print('</font></p>');
template.print('<p><font size="4" color="#808080" face="helvetica">');
template.print(gs.getMessage('The incident will automatically close '));
var days = parseInt(gs.getProperty("glide.ui.autoclose.time"));
var hours = days * 24;

if (days == 0)
template.print(gs.getMessage('now'));
else if (days <= 3) {
if(hours == 1)
template.print(gs.getMessage('in {0} hour', hours.toString()));
else
template.print(gs.getMessage('in {0} hours', hours.toString()));
}
else {
if(days == 1)
template.print(gs.getMessage('in {0} day', days.toString()));
else
template.print(gs.getMessage('in {0} days', days.toString()));
}
template.print('</font></p>');
})(current, template, email, email_action, event);

Hi,

 

Thanks you so much for your efforts. Its working fine.

 

Regards,

Nandan