- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 03:42 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 07:11 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 06:47 AM
Hi,
Not sure why we need 2 widgets, but Try something like this
Body HTML Template
<a href=<link1> ng-if="c.iscatrole==='true'">Create New Incident</a>
<a href=<link2> ng-if="c.iscatrole==='false'">Create New Incident</a>
Create a Script Include with a Method that retrieves the current role of the user (gs.hasRole)
Client Controller:
Use GlideAjax and get the answer from the above script include
Then, change the c.iscatrole value to "true" / "false" based on the response from GlideAjax
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 07:02 AM
Hi Narsing,
Thanks for the reply. This is not for catalog item. I have created custom pages in service portal, in which I placed two icon link widgets, because I Have two custom tables so that I used two widgets and made each of them redirect to each table, For suppose clicking on widget A redirects to "Student table" form in instance and clicking on widget B redirects to "Application form" in instance.
By clicking on create new widget, it redirects the respective form in screenshot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 07:11 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 07:30 AM
Hi Shivani,
Thanks for the reply. Yes I cloned and named it as Custom Icon Link, but the thing here is I used the same Custom Icon link widgets two times, so if I write above script in widget level, it works for both widgets right, but i have two different roles for two different tables "student and application form". For suppose if I give gs.hasRole("u_student_user") can create record, then even though he doesn't have role for another table, he can create record right.
In order to avoid this, I got an idea of cloning the icon link widget again, and can give another role there in server script. Can I proceed with this?