- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2024 04:00 AM
The FIRST thing I always do when getting unexpected results is log, log, log. Temporarily adding something like this will confirm this Script Include is running, the value passed in from the client, the user it is running as, and the record retrieved by the GlideRecord. This should help you see what is going wrong in your specific instance.
var HRTT4UTicket = Class.create();
HRTT4UTicket.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getJobTitleCodeHRIS: function() {
var sysid = this.getParameter('sysparm_sysid');
gs.info('HR SI running with import table sys_id = ' + sysid + ' running as user ' + gs.getUserName());
try {
var ghjobGR = new GlideRecord('sn_hr_core_greenhouse_job_import');
ghjobGR.addQuery('sys_id', sysid);
ghjobGR.query();
if (ghjobGR.next()) {
gs.info('HR SI record found ' + ghjob.getValue('u_jobcodehris'))
//var objReturn = {
// jobcodeHRIS : ghjobGR.JobCodeHRIS.toString()
//};
//return JSON.stringify(objReturn);
return ghjobGR.u_jobcodehris;
}
else {
gs.info('HR SI record not found')
return 'nothing';
}
}
catch(e) {
return 'error' + e;
}
},
type: 'HRTT4UTicket'
});
If you are finding that the logged field value is null, undefined, or empty and have confirmed that it indeed is not for the same record, ensure that the user the script is running as has the User role specified in the Controls tab of your custom table definition. When making any kind of access change, be sure to end impersonation or log out before re-testing. Confirm that the user the script is running as can view the record retrieved by the GlideRecord.