RE: UNEXPECTED_ERROR (TypeError: null is not a function, it is object. (NLRecordScripting.scriptInit$sys#495(eval)#1) )

Hi,

I am creating the timesheet through the scripting but it is not created.

I am getting the UNEXPECTED_ERROR (TypeError: null is not a function, it is object. (NLRecordScripting.scriptInit$sys#495(eval)#1) ).

This is the script for creating the timesheet.

var recObj=nlapiCreateRecord(‘timesheet’,{recordmode:’dynamic’});
nlapiLogExecution(‘Debug’,’recObj’,recObj);
var date=nlapiStringToDate(’10/20/2019′);
nlapiLogExecution(‘Debug’,’date’,date);
recObj.setFieldValue(‘trandate’,date);
recObj.setLineItemValue(‘timeitem’,’customer’,1,956);
recObj.setLineItemValue(‘timeitem’,’casetaskevent’,1,51);
recObj.setLineItemValue(‘timeitem’,’item’,1,13);
recObj.setLineItemValue(‘timeitem’,’hours4′,1,’2:00′);
recObj.setLineItemValue(‘timeitem’,’hourstotal’,1,’2:00′);
var recId=nlapiSubmitRecord(recObj,true,true);
nlapiLogExecution(‘Debug’,’recId’,recId);
var recObj1=nlapiLoadRecord(‘timesheet’,recId);
var trandate= recObj1.getFieldValue(‘trandate’);
nlapiLogExecution(‘Debug’,’trandate’,trandate);

 

RE: UNEXPECTED_ERROR (TypeError: null is not a function, it is object. (NLRecordScripting.scriptInit$sys#495(eval)#1) )

 

Can you please help me anyone on this issue.

samallasravan564 Rookie Asked on October 28, 2019 in SuiteScript.
Add Comment
2 Answers

dmashburn3 is right here. You need to first select the line, set vales, commit lines subrecord, commit line object and then finally submit timesheet object. Please see the API calls below for reference. You may find more details in the NetSuite help under ‘Timesheets Guide’- /app/help/helpcenter.nl?fid=section_3891941390.html

var obj = nlapiCreateRecord(‘timesheet’, {“recordmode”:”dynamic”});

obj.selectNewLineItem(‘timegrid’);

var sublistSubrecord = obj.createCurrentLineItemSubrecord(‘timegrid’, ‘sunday’);

sublistSubrecord.setFieldValue(‘customer’, ’48’);

sublistSubrecord.setFieldValue(‘item’, ‘117’);

sublistSubrecord.setFieldValue(‘location’, ‘1’);

sublistSubrecord.setFieldValue(‘hours’, ‘8:00’);

sublistSubrecord.setFieldValue(‘memo’, ‘timeentry created’);

sublistSubrecord.setFieldValue(‘isbillable’, ‘T’);

sublistSubrecord.setFieldValue(‘payrollitem’, ‘2’);

sublistSubrecord.setFieldValue(‘paidexternally’, ‘T’);

sublistSubrecord.setFieldValue(‘price’, ‘1’);

sublistSubrecord.setFieldValue(‘overriderate’, ‘T’);

sublistSubrecord.setFieldValue(‘department’, ‘1’);

sublistSubrecord.setFieldValue(‘class’, ‘1’);

sublistSubrecord.commit();

obj.commitLineItem(‘timegrid’);

var id = nlapiSubmitRecord(obj);

Beginner Answered on October 29, 2019.

Thank you for your response.

on October 30, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.