can any one help me out i want to update timesheet...
# general
a
can any one help me out i want to update timesheet weekof date field via script ,when i try to set the date of weekof via script it sets the current weekof but when i set date of weekof of last month manually it it able to set but cant set that via script. I want to set the weekof of last month via script.every response will appretiated
j
@Arham Momin In NetSuite, the timesheet "weekof" field is a read-only field, which means that it cannot be updated via script. The field is automatically populated based on the date of the timesheet. However, you can achieve the same result by creating a new timesheet with the desired "weekof" date via script.
var timeSheet = nlapiCreateRecord('timesheet'); timeSheet.setFieldValue('employee', employeeId); // set the desired "weekof" date var weekofDate = nlapiAddMonths(nlapiDateToString(new Date()), -1); timeSheet.setFieldValue('weekof', weekofDate); // set other fields as needed // ... var timeSheetId = nlapiSubmitRecord(timeSheet);
In the above example, a new timesheet record is created and the "weekof" field is set to the date of last month. Keep in mind that the date should be passed in the format of string. It's worth to mention that this will create a new timesheet with the "weekof" date you want, instead of updating an existing one.
a
sir very very thanks for response i ll sure try it
SIr above example is in 1.0 version ,i had code in 2.1 version ,is nlapiAddMonths works in 2.1
in your code sir you are passing date in string format ,if i pass my date in string format then it will set that date which i want to set