Email link for non-ITIL users redirects to form view instead of portal ticket view

Itsmehiiiiiiii
Tera Contributor

Hi everyone,

I’m working on an email notification that includes a “Take me to Incident” button.
The expected behavior is:

  • ITIL users: redirected to the backend form view

  • Non-ITIL users: redirected to the Service Portal ticket view (e.g. sp?id=ticket&table=incident&sys_id=...)

However, when a non-ITIL user clicks the link, it opens the form view in the portal (sp?id=form&table=incident...) instead of the proper ticket view.

Here’s the script I’m currently using in the mail script:

 

var user = current.opened_by || current.caller_id || gs.getUserID();
var userObj = new GlideRecord('sys_user');
userObj.get(user);

var link;

// Check if user has ITIL role
var hasITIL = new GlideRecord('sys_user_has_role');
hasITIL.addQuery('user', user);
hasITIL.addQuery('role.name', 'itil');
hasITIL.query();

if (hasITIL.next()) {
// ITIL user direct to backend
link = gs.getProperty('glide.servlet.uri') + 'nav_to.do?uri=' + current.sys_class_name + '.do?sys_id=' + current.sys_id;
} else {
// Non-ITIL directs to portal
link = gs.getProperty('glide.servlet.uri') + 'sp?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id;
}

 

Is there something that might be forcing or overriding the redirect for non-ITIL users?
Has anyone encountered a similar issue where the email link defaults to the form view?

Any suggestions or insights would be really appreciated.

Thanks!

0 REPLIES 0