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

Hi Shivani,

I have modified the server script as you suggested, but it is not working. It is opening the form and showing "Security constraints prevent access to requested page" which comes by default.

find_real_file.png

For which selection?

Sorry, selection means?

For catalog form or the custom table form, which part is throwing error

for custom table it is throwing the error, usually if user doesn't have access to the table, it throws the same error in general. Even before writing this server script, if i logged in with user who doesn't have access to student table, if he clicks on create new, it has shown the same error.