ANS-1743 · SUITESCRIPT DEVELOPMENT
How to Access Time Tracking Record Fields in NetSuite SuiteScript 2.x
Understand the distinct SuiteScript 2.x methods required to retrieve field values from both single and weekly time tracking records in NetSuite.
Short answer
When scripting for NetSuite time tracking, it is crucial to use different SuiteScript 2.x methods for single versus weekly time entries. While both utilize the same underlying record type, single time tracking fields are accessed directly as body fields, whereas weekly time tracking data resides within sublists, requiring specific sublist value retrieval functions.
Scenario
Developers encounter challenges when creating SuiteScript solutions for NetSuite time tracking pages, particularly when the script needs to function correctly across both single time tracking and weekly time tracking interfaces. Despite using the same record type, attempts to access field values using a single method often result in blank or incorrect data, as the presentation of fields differs significantly between these two pages.
Solution
To correctly access field values on both single and weekly time tracking pages using SuiteScript 2.x, developers must differentiate their approach based on the page context.
For Single Time Tracking Pages: Field values are accessed directly as body fields of the record.
javascriptrecord.getValue({ fieldId: 'customer' });This method retrieves the value of the 'customer' field from the main record body.
For Weekly Time Tracking Pages: Field values are located within sublists, requiring specific sublist value retrieval methods.
javascriptrecord.getSublistValue({ sublistId: 'timeitem', fieldId: 'customer', line: lineNum });This method retrieves the value of the 'customer' field from the 'timeitem' sublist at a specified lineNum.This distinction ensures that scripts accurately capture data regardless of whether time is being entered individually or as part of a weekly timesheet.
Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
