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

Hard to tell without seeing your code. If you get backend url in both cases then your condition must be incorrect or you might be checking for a user you think is external but still has some roles.

Try opening the link in an incognito window and then logging in with the credentials of a non-itil user, you should be redirected to the portal.

If you're not, check you have the following system properties set up (details taken from SPEntryPage script include)

* PROPERTY VALUE
* glide.entry.page.script new SPEntryPage().getLoginURL();
* glide.entry.first.page.script new SPEntryPage().getFirstPageURL();

I have same requirement. Please elaborate more. 

 

Regards.

Anji

Can you try this code once and tell me

displayLinks();
function displayLinks() {
  var getUser = new GlideRecord('sys_user');
  getUser.addQuery('email',email.to); 
  getUser.query();
  if(getUser.next()) {
    var currentUser = gs.getUser();
    if (currentUser.getUserByID(getUser.sys_id).hasRole("itil")) {
         var displayLink = 'your_backend_link';
    } else {
         var displayLink = 'your_portal_link';
    }
    template.print(displayLink +  "<br />");
  }
}