We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Can't get checkbox value to be recognized in script include

Neil Wallace
Tera Contributor

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:

find_real_file.png

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;
},

 

 

 

 

find_real_file.png

24 REPLIES 24

Hi,

can you share dictionary screenshot for checkbox?

Is the field name correct which is used in reference qualifier?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

find_real_file.png

 

 

javascript: var query = 'active=true^customer=true^u_pharmacy=' + current.u_pharmacy; query;

Thanks again Ankur, yes it all seems correct. And yet.. it just doesnt recognize it as true.

 

 

 

 

 

vkachineni
Mega Sage

I see the company field as a dropdown with --None--

Can you set choice list specification of company as Choice None instead of dropdown so it shows up as a list picker.

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Neil Wallace
Tera Contributor

find_real_file.png

Set that to --None-- so it shows up as a pick list.

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022