- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2016 01:43 PM
// Using a single test OHF with little data and a closed RITM
var OHF = new GlideRecord('u_ob_openhirefulfillment');
var lm = "OH_test_rig_3";
OHF.get("cbe0a2be2b7c664091d580a119da1511"); // hard coding for testing only
gs.log("First name: " + OHF.u_first_name, lm); // verify we got the test record
// get RITM
var ritm = OHF.u_fksc_req_item_request.getRefRecord();
gs.log("get returned RITM: " + ritm.getDisplayValue());
gs.log('OHF request field: ' + OHF.u_fksc_req_item_request, "openHire");
gs.log('ritm value: ' + ritm.sys_id, "openHire");
try {
var myOHF = new GlideRecord('u_ob_openhirefulfillment');
var RITMSID = ritm.sys_id;
myOHF.addQuery('u_fksc_req_item_request', 'RITMSID');
myOHF.query();
if (myOHF.next) {
gs.log("last error msg; " + myOHF.getLastErrorMessage());
gs.log('OHF in email scripting is ' + myOHF.getDisplayValue(), "openHire");
gs.log("First name: " + myOHF.u_first_name, lm); // verify we got the test record
} else {gs.log('query returned nothing for ' + ritm.getDisplayName()); }
} catch (err) {gs.log('query returned nothing for ' + ritm.getDisplayName()); }
The logs show that the ritm is successfully read and gs.log output shows the value of the RITMSID field is the sys_id stored on the u_ob_openhirefulfillment's u_fksc_req_item_request field.
The problem is that no errors are thrown and the myOHF.u_first_name displays a blank, even though the field is valued based on the first log message.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2016 04:18 PM
There are few syntax errors. Try this
var OHF = new GlideRecord('u_ob_openhirefulfillment');
var lm = "OH_test_rig_3";
OHF.get("cbe0a2be2b7c664091d580a119da1511"); // hard coding for testing only
gs.log("First name: " + OHF.u_first_name); // verify we got the test record
// get RITM
var ritm = OHF.u_fksc_req_item_request.getRefRecord();
gs.log("get returned RITM: " + ritm.number);
gs.log('OHF request field: ' + OHF.u_fksc_req_item_request, "openHire");
gs.log('ritm value: ' + ritm.sys_id, "openHire");
try {
var myOHF = new GlideRecord('u_ob_openhirefulfillment');
var RITMSID = ritm.sys_id;
myOHF.addQuery('u_fksc_req_item_request', RITMSID);
myOHF.query();
if (myOHF.next()) {
gs.log("last error msg; " + myOHF.getLastErrorMessage());
gs.log('OHF in email scripting is ' + myOHF.getDisplayValue(), "openHire");
gs.log("First name: " + myOHF.u_first_name); // verify we got the test record
} else {gs.log('query returned nothing for ' + ritm.getDisplayName()); }
} catch (err) {gs.log('query returned nothing for ' + ritm.getDisplayName()); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 07:44 AM
Abhinay,
Thank you for finding my syntax error, I couldn't see. The use case is a context where I have a RITM object but need a OHF object. The OHF has a foreign key to the RITM, but the reverse isn't true. It only happens in one place so far, where I have a RITM w/o an OHF in hand. It should have been a slam dunk to get it, but my coding error may it harder than necessary.
Reg Walker
Application Developer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 07:46 AM
Glad you got this working.