Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Dear all, 

 

Thankyou very much very your help without which I would have been totally lost.

Using 

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

 

Will indeed get the dropdown to work 🙂 

 

The problem now is that it seems to clash with this attribute

ref_auto_completer=AJAXReferenceChoice,max_ref_dropdown=1000

 

This attribute is there because the form is a self registration form to be used by the public, and it won't allow access to the customer table. This attribute seems to have to be there for this to work. 

Hopefully screenshot can explain

 

 

 

 

 

 

 

 

@Neil Wallace 

I didn't understand why company field on form needs to be drop down?

It should be reference type

Regards
Ankur

 

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

Neil Wallace
Tera Contributor

find_real_file.png

Neil Wallace
Tera Contributor

Issue:

Removing this attribute

ref_auto_completer=AJAXReferenceChoice,max_ref_dropdown=1000

Stops dropdown from populating on public login in.

However removing this attribute is needed to  get this query to work in advanced reference qualifier:

 

 

 

 

 

 

Neil Wallace
Tera Contributor

Sorry some misinformation given . The issue is when you change from dropdown with none to none then it stops working on public domain. However the none is needed to get it to work on public.

find_real_file.png