Can the visibility of the catalog item (service catalog) can be restricted by employee type? I want to restrict a catalog item for employee type contractors. What is the best can be be done for this, so that no contractors can see the catalog item?

Eva2
Kilo Contributor

Can the visibility of the catalog item (service catalog) can be restricted by employee type?

I want to restrict access for a catalog item of employee type contractors.

What is the best can be be done for this, so that no contractors can see the catalog item?

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Namita,

 

You should be able to restrict the visibility of the catalog items via User criteria (Advanced Script).

Script below:

checkEmployeeType();

function checkEmployeeType() {

    var user = new GlideRecord('sys_user');
    user.get(gs.getUserID());
    user.query();
    if (user.u_employee_type == 'contractor') //assuming u_employee_type is the column name
    {
        return false;
    }
    return true;
}

Details here https://docs.servicenow.com/bundle/orlando-it-service-management/page/product/service-catalog-manage...

 

- Pradeep Sharma

View solution in original post

5 REPLIES 5

Tanvi Jain
Kilo Contributor

Hi Namita,

Assuming, you have a field "Employee Type" in your user table. In the catalog item, under available for you can GlideRecord and get the sys_id for users you are not contractors.

var gr = new GlideRcord('sys_user');
gr.addQuery('employee_type','!=','contractor');

gr.addQuery('sys_id',gs.getUserID());
gr.query();
if(gr.next())
{
return true;
}

 


Please mark reply as Correct/Helpful, if applicable. Thanks!

Regards,

Tanvi

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Namita,

 

You should be able to restrict the visibility of the catalog items via User criteria (Advanced Script).

Script below:

checkEmployeeType();

function checkEmployeeType() {

    var user = new GlideRecord('sys_user');
    user.get(gs.getUserID());
    user.query();
    if (user.u_employee_type == 'contractor') //assuming u_employee_type is the column name
    {
        return false;
    }
    return true;
}

Details here https://docs.servicenow.com/bundle/orlando-it-service-management/page/product/service-catalog-manage...

 

- Pradeep Sharma

thanks Pradeep it worked

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

You are very welcome Namita.