User Criteria on catalog item

Ram050670
Tera Guru

Hi All,

i am looking for a User criteria on catalog item that will be available for only Employee type Employee and active True. 
how to filter the users with employee type? 

usually we add groups and role on the available for but in this case we need Employee type Employee and active user.

2 ACCEPTED SOLUTIONS

Ashir Waheed
Kilo Sage
Kilo Sage

Hi @Ram050670 

 

You will need to create a New User Criteria (user_criteria) record

  1. In the Application navigator, Navigate to the Service Catalog->Catalog Definition->User Criteria
  2. Check the Advanced check box.
  3. AshirWaheed_1-1708461220215.png
  4. Write the script as you return the desired filter user.
  5. AshirWaheed_0-1708462342835.png
  6. Save the Record.
  7. Go to your catalog item in the Available for related list and Edit the list and enter the user criteria you created.
    AshirWaheed_2-1708461530567.png

     

Script:

var user = new GlideRecord("sys_user");
//Change filter according to yours variable names
user.addEncodedQuery("employee_typeSTARTSWITHEmployee^active=true");
user.query();
while(user.next()){
answer=true;
}

 

This will resolve your requirement.

 

Regards,

Ashir Waheed

 

View solution in original post

tried this it worked for me: 

 

 
var EmpType = gs.getUser().getRecord().getDisplayValue('u_employee_type');

if (EmpType == 'Employee') {
    condition = true;
} else {
    condition = false;
}

View solution in original post

7 REPLIES 7

tried this it worked for me: 

 

 
var EmpType = gs.getUser().getRecord().getDisplayValue('u_employee_type');

if (EmpType == 'Employee') {
    condition = true;
} else {
    condition = false;
}

I believe you will run into issues with using the gs.getUser() function  in user criteria. I would recommend using the approach I outlined above.

i will try and see.