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 06:39 AM
Thanks Ankur, have tried your suggestions same thing in the log. Doesnt recognize checkbox as ticked, though does understand it is there.
changed to--->
javascript:new global.GetGPsPharmacySelfRegistration().GetGPsPharmacySelfRegistration1(current.u_pharmacy)
var GetGPsPharmacySelfRegistration = Class.create();
GetGPsPharmacySelfRegistration.prototype = Object.extendsObject(AbstractAjaxProcessor, {
GetGPsPharmacySelfRegistration1: function(ph) {
var gr = new GlideRecord('core_company');
gr.addQuery('active', 'true');
gr.addQuery('customer', 'true');
gs.log('outside');
gs.log('check' + ph.toString());
if (ph.toString() == 'true'){
gs.log('inside');
gr.addQuery('u_pharmacy', 'true');
}
gr.query();
var companies='';
while (gr.next()) {
companies += ',' + gr.sys_id;
}
return 'sys_idIN' + companies;
},
type: 'GetGPsPharmacySelfRegistration'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:03 AM
then do the validation on change of checkbox and inform user about the invalid company selected on form
If my response helped please mark it correct and helpful to close the thread.
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 07:14 AM
Hi Anwar thanks- there are no invalid companies selected on the form.
The issue is that the script include does not recognize if the checkbox has been ticked or not. It always defaults it to false.
That's the issue.
But thanks again for your suggestions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:14 AM
The script include always believes it to be false I should say.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 07:15 AM
Hi,
Did you add in log what came for the value of checkbox?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
