need change the REQUESTED FOR field filter conditions based on custom field values in SR form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 01:50 PM
Hi Experts,
In on-change/onload catalog client script-
need change the REQUESTED FOR field filter conditions based on custom field values in SR form like if we select custom field ( user type).
Here we have 2 custom fields like User type and Requested for
User type have 2 options like employee and non employee
If we select employee then in Requestedvfor field should contain @employee.com related users only
if we select non employee then in requested for field should filter/contains @nonemployee.com. related users only.
please assist me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 02:40 PM - edited 12-26-2023 02:41 PM
@Purushotham Ga2 : This cannot be implemented via client scripts and can be achieved via reference qualifiers. With the simple if-else condition in the reference qualifier, you will be able to achieve the requirement.
Below is the sample code and the screenshot. In my use case, based on the choice value, I am showing users whose email contains "example.com" and does not contain "example.com.". Replace with your exact conditions and give a try.
javascript: if(current.u_choice_field_1==3) 'emailLIKEexample.com'; else 'emailNOT LIKEexample.com';
Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 08:30 PM
@Purushotham Ga2: Did my response address your question, or is there anything else I can help you with?
Please mark this as correct answer and helpful if it resolved. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 10:29 PM
Hello @Purushotham Ga2
- Create one script include.var Filter_User = Class.create();Filter_User.prototype = {initialize: function() {},filterUser: function(user_type) {var user = '';var gr_user = new GlideRecord('sys_user');if(user_type == 'employee'){gr_user.addEncodedQuery('emailLIKE@employee.com');gr_user.query();while(gr_user.next()){user = user + ',' + gr_user.sys_id;}}else if(user_type == 'nonemployee'){gr_user.addEncodedQuery('emailLIKE@nonemployee.com');gr_user.query();while(gr_user.next()){user = user + ',' + gr_user.sys_id;}}return 'sys_idIN' + user.toString();},type: 'Filter_User'};2. Add below line in reference qualifier of requested for :javascript: new Filter_User().filterUser(current.u_user_type);
Pradnyesh Dhapare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 10:44 PM
If your Requested for variable is in Reference type, you can set the Reference Qualifier in the Requested for variable.
Sample below.
(current.variables.user_type.toString() === 'employee') ? 'active=true^emailLIKE@employee.com' : (current.variables.user_type.toString() === 'non_employee') ? 'active=true^emailLIKE@nonemployee.com' : 'sys_id=-1';
Cheers,
Tai Vu