How to configure links in email script? it has to redirect to front end portal for an end user and to backend for an itil user

reeba1
Tera Contributor

Hello,

There is a link given in the notification body.

The requirement is when an end user clicks on the link it should redirect to the front end portal and when an itil user clicks on the same link, it should redirect to the backend. 

How can i configure the link in email script?

When i open a ticket in front end, the url is in this form :

https://testinstance.service-now.com/test_portal/?sys_id=sysid number&view=sp&id=ticket&table=incide...

Can someone help me in configuring this link in email script?

Regards,

Reeba

13 REPLIES 13

Dubz
Mega Sage

You should be able to give the same URL to everyone, there is a script include called SPEntryPage that controls whether a user is redirected to the service portal or the frameset page.

reeba1
Tera Contributor

Hello David,

 

Actually when a ticket is created, a notification needs to be sent with the details of the ticket created.

And in that notification there should be a link which would direct the users to the ticket in frontend portal if they are end user and to the backend if tehy are itil users.

That should be done using email scripts right?

Regards,

Reeba

If you look at the OOB mail script called 'incident_take_me_to_the_incident' you can see current.getLink() is used in there so that's one option.

Another option is to construct the URL something like:

template.print('<a href="' + gs.getProperty('glide.servlet.uri') + gs.generateURL(current.getTableName(), current.getUniqueValue()) + '">' + current.number + '</a>';
	

asifnoor
Kilo Patron

Hi,

As David Suggested, the OOB SN will take care of the redirction. But if you still wnat to do this with the email script, try this code.

displayLinks();
function displayLinks() {
   //Check if the user has role itil
   if (gs.hasRole("itil")) {
         var displayLink = 'your_backend_link';
   } else {
         var displayLink = 'your_portal_link';
   }
      template.print(displayLink +  "<br />");
}

Mark the comment as a correct answer and also helpful once worked.