Hi, While running the following Script it returns ...
# suitescript
p
Hi, While running the following Script it returns unexpected error. I migrated the API version to 2.0 and made Possible changes but the error remains the same. require([ 'N/record' , 'N/log' ], function (record, log) { var siteRecord = record.load({ type: 'website', id: SiteId, isDynamic: false }); log.debug('Site Record:', JSON.stringify(siteRecord)) siteRecord.insertLine({ sublistId: 'fieldset', line: linecount }); siteRecord.setSublistValue({ sublistId: 'fieldset', fieldId: 'fieldsetname', value: 'Test' }); siteRecord.save(); }); Can anyone help me out.
c
What's the full error message?
p
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "UNEXPECTED_ERROR",
  "message": null,
  "stack": [
    "<anonymous>(N/record/recordService.js)",
    "<anonymous>(adhoc$-1$debugger.user:14)",
    "<anonymous>(adhoc$-1$debugger.user:1)"
  ],
  "cause": {
    "type": "internal error",
    "code": "UNEXPECTED_ERROR",
    "details": null,
    "userEvent": null,
    "stackTrace": [
      "<anonymous>(N/record/recordService.js)",
      "<anonymous>(adhoc$-1$debugger.user:14)",
      "<anonymous>(adhoc$-1$debugger.user:1)"
    ],
    "notifyOff": false
  },
  "id": "216197f1-a7d3-4b61-aee6-166a2ca8da12-2d323031392e30332e3235",
  "notifyOff": false,
  "userFacing": false
}
c
SiteId and linecount don't seem to be declared or set
n
Can you share your equivalent working Ss1.0 code
p
siteRecord.selectNewLineItem('fieldset') siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetname', fieldsetname) siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetid', fieldsetid) siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetrecordtype', 'ITEM') siteRecord.setCurrentLineItemValue('fieldset', 'fieldsetfields', finalFieldsetArray) siteRecord.commitLineItem('fieldset')
n
I sthis code working? I don't remember "setcurrentSublistValue" shouldn't it be CurrentLineItemvalue?
Also, in your 2.0 code, you need to use ''' siteRecord.selectNewLine(sublistId:: 'fieldset') ''' instead of ''' siteRecord.insertLine({ sublistId: 'fieldset', line: linecount, }); '''
p
Cannot find function selectNewLine in object standard record. This is the error I am getting when I use selectNewLine()
n
I think that works only in dynamic mode
If you don't want to use dynamic mode, then insertLine is the way to go, but as you are converting this coed from 1.0 to SS-2.0, please make sure that the linenum indexing in SS-1.0 starts from ' 1 ' whereas in SS-2.0 it starts from ' 0 '
z
you have an extra comma in your insertLine function
delete the comma after “line: linecount”
n
@zach_calh Eagle eyes 🦅 👀
z
but you should also be setting the line number with setSublistValue, too!
because you are in standard mode, you have to explicitly state the line
s
standard mode rocks.
p
Still it shows the same error Error:{"type":"error.SuiteScriptError","name":"UNEXPECTED_ERROR","message":null,"stack":["<anonymous>(N/record/recordService.js)","<anonymous>(adhoc$-1$debugger.user:43)","<anonymous>(adhoc$-1$debugger.user:1)"],"cause":{"type":"internal error","code":"UNEXPECTED_ERROR","details":null,"userEvent":null,"stackTrace":["<anonymous>(N/record/recordService.js)","<anonymous>(adhoc$-1$debugger.user:43)","<anonymous>(adhoc$-1$debugger.user:1)"],"notifyOff":false},"id":"95e317f2-7239-4ddf-a3aa-0dd2098fd8f4-2d323031392e30332e3235","notifyOff":false,"userFacing":false}