Script Include isn't working on Variable for Record Producer

Community Alums
Not applicable

Hey Everyone, 

 

We have a script include that is being called in a variable list collector. In the reference qualifier section we have the following javascript: new dtbeLocation().NTIPJurisdiction(current.variables.u_state_name); 

 

Our script include isn't client callable, but it works on the standard ui as an advanced reference qualifier for a glide_list field.javascript: new dtbeLocation().NTIPJurisdiction(current.u_state_name); 

 

We are using the same field name as in the standard ui for u_state_name. 

What are we doing wrong? 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hey Everyone! 

 

Yes, it has to be client callable to work. After changing the script include into a client callable, it worked. Thank you all for your help. 

View solution in original post

10 REPLIES 10

Brad Bowman
Kilo Patron
Kilo Patron

I'm assuming on this record producer you have a variable named u_state_name that you are populating after the form loads?  Is this mapped to a field or not?  I'm not sure that it matters in this case.  The List Collector is going to load when the form loads, so before the variable is populated.  Add this to the Variable attributes so that the List Collector is updated when the state variable changes

ref_qual_elements=u_state_name

Then in the Script Include, if you haven't already done so, log the argument that u_state_name is getting passed into to determine if it is reaching the SI.

Community Alums
Not applicable

Screenshot 2023-05-30 092338.png

 

This is what I have, but it still isn't working. The script include isn't client callable, but it still works in the standard ui. Not sure what  I am doing wrong here.

Ankur Bawiskar
Tera Patron
Tera Patron

@Community Alums 

for it to work from reference qualifier there is no dependency with client callable

can you share that script include script?

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

Community Alums
Not applicable
var dtbeLocation = Class.create();
dtbeLocation.prototype = {
	initialize: function() {
	},

	NTIPJurisdiction : function(state) {
		var sysIDs = [];
		var gr = new GlideRecord("x_g_cfd_dtbe_help_location");
		gr.addEncodedQuery("element=jurisdictions^application=NTIP Application^u_state_id="+state);
		gr.query();
		while(gr.next()) { 
			sysIDs.push(gr.getUniqueValue()); 
		}
		return "sys_idIN"+sysIDs.toString();
	},
	
	NTSSCountyAccess : function(state) {
		var sysIDs = [];
		var gr = new GlideRecord("x_g_cfd_dtbe_help_location");
		gr.addEncodedQuery("element=counties^application=NTSS Application^u_state_id="+state);
		gr.query();
		while(gr.next()) { 
			sysIDs.push(gr.getUniqueValue()); 
		}
		return "sys_idIN"+sysIDs.toString();
	},
	 
	 TBGIMSCountyAccess : function(state) {
		var sysIDs = [];
		var gr = new GlideRecord("x_g_cfd_dtbe_help_location");
		gr.addEncodedQuery("element=counties^application=TB-GIMS Application^u_state_id="+state);
		gr.query();
		while(gr.next()) { 
			sysIDs.push(gr.getUniqueValue()); 
		}
		return "sys_idIN"+sysIDs.toString();
	},
	
	 LabNames : function(state) {
		var sysIDs = [];
		var gr = new GlideRecord("x_g_cfd_dtbe_help_location");
		gr.addEncodedQuery("element=lab_names^application=TB-GIMS Application^u_state_id="+state);
		gr.query();
		while(gr.next()) { 
			sysIDs.push(gr.getUniqueValue()); 
		}
		return "sys_idIN"+sysIDs.toString();
	},
	
	 NTSSCRCountyAccess : function(state) {
		var sysIDs = [];
		var gr = new GlideRecord("x_g_cfd_dtbe_help_location");
		gr.addEncodedQuery("element=counties^application=NTSS-CR Application^u_state_id="+state);
		gr.query();
		while(gr.next()) { 
			sysIDs.push(gr.getUniqueValue()); 
		}
		return "sys_idIN"+sysIDs.toString();
	},
	
	type: 'dtbeLocation'
};