Glide Record is always empty

bigbacon
Giga Guru

I am trying to get a script to go look up a record and grab a value to return during an onChange event.

 

I have this include:

var HRTT4UTicket = Class.create();
HRTT4UTicket.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getJobTitleCodeHRIS: function() {
		var sysid = this.getParameter('sysparm_sysid');

		try {
			var ghjobGR = new GlideRecord('sn_hr_core_greenhouse_job_import');
			ghjobGR.addQuery('sys_id', sysid);
			ghjobGR.query();
			
			if(ghjobGR.next()) {
				//var objReturn = {
				//	jobcodeHRIS : ghjobGR.JobCodeHRIS.toString()
				//};
				//return JSON.stringify(objReturn);
				return ghjobGR.JobCodeHRIS;
			}
			else {
				return 'nothing';
			}	
		}
		catch(e) {
			return 'error' + e;
		}		
	},
    type: 'HRTT4UTicket'
});

 

and what seems to be happening is even though I am sending a valid sys_id to this function, it just returns an empty record set for the given table, which causes it to always send a null value back.

 

I cannot figure out why this doesn't work. The sys_id being sent is valid, I can go to the table data list manually and look up the record but it will not do it through this client script. We have other similar scripts that seem to work just fine. 

 

I have also tried it as just a .get(sys_id) and that return the same result. 

 

It is like the script doesn't have access to the table yet it does?

 

I can make the script just return any random string and it gets returned just fine.

 

What am I missing here? 

21 REPLIES 21

I can take the sys_id being sent, go to the Table data and find that sys_id. I can also use the tables API and find the record using the sys_id.

 

The javascript script GET(sysid) ALWAYS returns a record set where every value is blank or null as if it found nothing.

I've messed with the role assigned to the table but knowing what to use is beyond what I know. I tried setting it to snc_internal so that it was open to all and that didn't change anything. 

 

How do I know what role the internal script is running as? 

 

My user role is an admin and I can access the table data so if the client script is supposed to run as myself in the browser, it still doesn't work. I suspect the permissioning is the issue here but I do not know how to resolve that. Other tables I look at that work correctly did not have to specify a role upon creation. "Create access controls" is checked by default and can't be unchecked where as other tables that work, this is not checked (and can't be checked)

 

caller access is "caller restriction"

Can read,create,update, and allow access to this table viaweb services are checked.

Accessible from all appliocation scopes.

 

Current user role is "SNC_Internal"

Try changing the Caller Access to -- None --.  The logs in the script that I added will show the user the script is running as, so you can make sure it's not something weird with no access. 

caller access changed nothing. I do not know how to gs.info thing works. 

 

the script include is running...

If you've run the script with the logs I suggested, look in the System Log > All in the left nav.  Filter on Messages starting with HR SI.