User Criteria not working - Requirement to restrict a group to see a Quick Link on portal

nirwan_ritik
Tera Contributor

Requirement: Restrict a group to see a particular quick link on the portal.

 

to achieve this, on the sn_ex_sp_quick_link record I have added a user criteria in the Available For related tab. But it's not restricting the group to see the Quick Link. Code is give below. Kindly assist me on this. 

 

var user = new GlideRecord('sys_user');
user.get(gs.getUserID());

var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', 'dc12144997547550fd6e77500153af2d'); // Gliding IT Approver group member
gr.query();
var flag = 0;


while (gr.next()) {
    if (gr.sys_id == user.sys_id) {
        flag++;
    } else {
        continue;
    }
}

if (flag > 0) {
    answer = false;
} else {
    answer = true;
}
3 REPLIES 3

Muhammad Hamza
Kilo Sage

Hey @nirwan_ritik ,

Instead of writing code, you can add user criteria by specifying a group there.

 

MuhammadHamza_0-1701449854439.png

MuhammadHamza_1-1701449900401.png

In this way, without writing code, you can restrict that quick link to that particular group.

 

Kindly appreciate the efforts of community contributors by marking appropriate response as the correct solution and helpful, this may help other community users to follow the right solution in the future.

Thanks,

Hamza

Marcus Walbridg
Tera Expert

can you share your user criteria?  this does not seem like something you have to script

Shane J
Tera Guru

This condition will never be met:

    if (gr.sys_id == user.sys_id) {

 

I think you want:

    if (gr.user == user.sys_id) {