Can't get checkbox value to be recognized in script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 05:51 AM
Really stuck on an issue and could value some help.
I want the reference qualifier query for the company field to depend on whether pharmacy is checked below:
Have created a reference qualifier as follows:
Passing current into the script include. While it recognizes values already saved to database eg. current state. It doesnt recognize values not saved eg. checkbox u_pharmacy.
Completely stumped. And any help much appreciated.
var GetGPsPharmacySelfRegistration = Class.create();
GetGPsPharmacySelfRegistration.prototype = Object.extendsObject(AbstractAjaxProcessor, {
GetGPsPharmacySelfRegistration: function(ph) {
var gr = new GlideRecord('core_company');
gr.addQuery('active', 'true');
gr.addQuery('customer', 'true');
gs.log('outside');
gs.log('current state' +ph.state);
gs.log('current u_pharmacy' +ph.u_pharmacy);
gs.log('current name' +ph.first_name);
gs.log('check' + current.getDisplayValue('u_pharmacy'));
if (ph.u_pharmacy){
gs.log('inside');
gr.addQuery('u_pharmacy', 'true');
}
gr.query();
var companies='';
while (gr.next()) {
companies += ',' + gr.sys_id;
}
return 'sys_idIN' + companies;
},
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:18 AM
try this in advanced ref qualifier
javascript: var query = 'active=true^customer=true^u_pharmacy=' + current.u_pharmacy; query;
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 08:13 AM
Please make the company field as Reference type and not choice and then the script I provided should work
javascript: var query = 'active=true^customer=true^u_pharmacy=' + current.u_pharmacy; query;
Reference qualifier works for reference, list and not for choice fields
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 08:18 AM
Yep it is a reference field not a choice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 08:41 AM
Can you check the choice list specification tab too.
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 08:14 AM
Hi Ankur,
Thanks again for help.
This is an improvement in that it simplifies matters. However it is still believing that current.u_pharmacy is always false.
Regardless of if the checkbox is ticked or not.
