Hi everyone, I am trying to do some calculations w...
# general
s
Hi everyone, I am trying to do some calculations with the hours in the NetSuite Timesheet via SuiteScript 2.0. However, I can only access the inputted hours after I save the record. But for line validation purpose I would like to access the total hours per line before the record is saved. Does anyone know how?
b
what does your attempt look like
s
by doing the following in validateLine function I can get all the sublist value id's: log.debug('Total time: ', timesheet.getSublistFields({ sublistId: sublistName, })) ["_sequence","_id","approvalstatus","billed0","billed1","billed2","billed3","billed4","billed5","billed6","cseg_progplat","cseg_progplat_display","editable","employeesub","hassupervisor","hours1","hourstotal","id","importedline","internalemployee","isbillable","isbillableenabled","isexempt","isproductive","isutilized","lastselectedbillable","linechanged","overriderate","posted0","posted1","posted2","posted3","posted4","posted5","posted6","statushours1","supervisorapproval","timebill1","timemodified","timetype","sys_id","sys_parentid","customer","rate","department","class","cseg_studynum","memo","custcol_bdo_line_memo","cseg_iteos_cs","cseg_iteos_cs_2","custcol_max_hours","item","casetaskevent","timebill0","statushours0","timebill2","statushours2","timebill3","statushours3","timebill4","statushours4","timebill5","statushours5","timebill6","statushours6","linechanged0","linechanged1","linechanged2","linechanged3","linechanged4","linechanged5","linechanged6","projecttaskassignment","hours0","memo0","memo1","hours2","memo2","hours3","memo3","hours4","memo4","hours5","memo5","hours6","memo6","BY_DAY_NUM_HOURS","BY_DAY_ID","BY_DAY_STATUS","BY_DAY_dayNum","BY_DAY_BILLED","BY_DAY_POSTED","BY_DAY_CHARGED","BY_DAY_TYPE","BY_DAY_memo"] However when logging them all out I can only get the amount of submitted hours (so after the whole timesheet record is saved). For example: log.debug('test field6: ', timesheet.getSublistValue({ sublistId: sublistName, fieldId: 'hourstotal', line: 0 })) will return the total hours that appear when the timesheet record is saved and not those that are currently written down in the timesheet.
b
expect to share enough code for someone else to reproduce the issue
at best, what you shared tells me you are using getSublistValue on some unknown sublist to get the hourtotal of the first line
so i can really only tell you that its more normal to use CurrentRecord.getCurrentSublistValue in a validateLine entrypoint
my suspicion is that timesheet isnt actually the currentRecord
you shouldnt be able to use getSublistFields on a currentRecord