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

ok cool, never knew that.

 

It is running as myself according to the thing.

I'm back to being stumped since you are getting the logs and it shows the expected sysid passed in, that means this you have access to the script and it is running.  Is the Script Include in the sn_hr_core scope?  If you try this same test scenario but first hardcode a sys_id from an out of box table record like sn_hr_core_case, and return the record in this script do you see the field values?

it is accessible from all application scopes.

 

So I added a case get from sn_hr_core_case using a valid sys_id and I was able to use the gs.info to then dump the case's sys_id and it was able to. So this leads me to believe it is a table access issue to just this one table.

Sounds like it, but you've confirmed the access settings are correct, the script is running as you, and you can manually view this record.  Have you checked to make sure there is not an 'execute' ACL on this table?  I'm not sure if having one would throw an error or do what you are describing.

How do I check excute ACL? That ACL box is schecked for the table and I wonder if that is the problem as other tables do not have that checked and therefore no explicit role has to be selected for the table. I don't know if that is older functionality though and that all new tables require it.