I have the following script, applied to the Timesheet record, which gets called when a change event occurs for any field on a Timesheet record. This works perfectly on a body field, but it fails on the fields inside the timegrid (a child of the Timesheet, I believe). All I am trying to do is simply show/hide a custom field based on the Customer a user chooses when adding time to a timesheet. I want to capture the event, check the customer, and if true hide another field.
The example below is just a starting point to test the isDisplay function. It hides whatever field fires the event. When testing it by changing the customer in the time grid, it fires, gets the correct id, which is literally 'customer', but then call to getField() returns null. However, getField() works fine if I pass it one of the body fields (like date for example).
EXAMPLE:
define(['N/currentRecord'], function () {
function fieldChanged(context) {
//get reference to whichever field is changing and hide it...
var f = context.currentRecord.getField({fieldId: context.fieldId});
f.isDisplay = false;
}
return {
fieldChanged: fieldChanged
}
}
);
Can anyone point me in the right direction? Is there another way I am supposed to get to the time grid fields? I'm brand new to SuiteScript.