Notification Email Script - System URL

michaelmorgan
Giga Contributor

Hi,

I've currently got a notification script set up to paste an ESS link if the user is not an ITIL user, but to do the opposite if they are. I was just wondering if there was any way I could change the script so that it's got the URL variable of the site, so that I do not have to make seperate changes for both dev and live versions of the instance? I mean in the way like ${URI_REF} does.

Here is my code so far, it works but if I was to clone live over my dev environment the links would all be broken as they'd point to the live URL:

if (gs.getUser().getUserByID(current.getValue('caller_id')).hasRole('itil') == true){

        return '${URI_REF}';

} else if (gs.getUser().getUserByID(current.getValue('caller_id')).hasRole('itil') != true){

        return '<a href="https://MyCompanyDev.service-now.com/ESS?sys_id=${sys_id}&view=sp&id=ticket&table=incident ">${number}</a>';

}

1 ACCEPTED SOLUTION

rahulpandey
Kilo Sage

Hi try below


return "<a href=" + gs.getProperty('glide.servlet.uri') + "/ESS?>LINK</a>";


View solution in original post

5 REPLIES 5

SanjivMeher
Kilo Patron
Kilo Patron

Try



var instance_name = gs.getProperty('glide.servlet.uri');



return '<a href="+instance_name+"/ess?...............................</a>';



Please mark this response as correct or helpful if it assisted you with your question.

rahulpandey
Kilo Sage

Hi try below


return "<a href=" + gs.getProperty('glide.servlet.uri') + "/ESS?>LINK</a>";


Thank you very much, that is perfect for what I need.


krushikesh
Kilo Guru

Hi Michel,



You can use the ServiceNow Properties to get the instance Name or URL



var instanceURL = gs.getProperty('glide.servlet.uri');


var instanceName = gs.getProperty('instance_name');



Ex:


return '<a href="'+instanceURL+'/ESS?"'



I hope it will work for you