How can we use icon link widget to redirect to different pages when user clicks on the widget based on his role in service portal?

rkreddy
Giga Expert

Hi Everyone,

Hope everything is going good.

I have two icon link widgets, "create new incident" and "Create new Custom table record" and each redirects to different pages in service now instance. For example, Widget A directs to Create new Incident record page and Widget redirects to Create new Custom table record page. Now, I want to make these widgets visible to all the users irrespective of their role, but if user doesn't have role on custom table, then when he clicks on "create new custom table record" widget, then he needs to redirect to the catalog item in service portal.

Thank you.

1 ACCEPTED SOLUTION

Shivani Singh1
Tera Guru

Hello,

You have to clone and customize Icon Link to have this functionality,

In server script, add these lines

if(gs.hasRole("<role name>"))

{

var gr = $sp.getInstanceRecord();
data.href = $sp.getMenuHREF(gr);

}

else

{

data.href = "?id=sc_cat_item&sys_id=<sys-id of catalog item>";

}

Fill <role name> & <sys-id> as per your requirement.

Please mark helpful if it solves the purpose.

View solution in original post

19 REPLIES 19

Ok after showing error, is user getting redirected to catalog item?

No Shivani, it is not redirecting.

Can you send me the URL which comes on click of widget?

Screenshot too

It should work

It is working fine Shivani. I have tested last night after replying you, it worked. And a small request further is, when user redirects to catalog item, how to display message like "You don't have role to open the table, please raise below access"

Thanks for all the help @Shivani . It is working fine. Stay safe Take Care.