kasarlaravi
kasarlaravi

Reputation: 57

SuiteScript 2.0 setValue not allowed in the current subrecord (Sales Order Record)

I'm trying to set a value for the sublist 'billingaddress/shippingaddress'. But the script fail with error "setValue not allowed in the current subrecord". However, I'm able to get the subrecord value.

I need to implement the below suitescript 1.0 to 2.0 on SALES ORDER record (Client Script).

nlapiSetFieldValue('billcity', "TEST");

I tried with below.

 var currentRecordata = currentRecord.get();
 var subrec = currentRecordata.getSubrecord({
    fieldId: 'billingaddress'
  });    

  subrec.setValue({
    fieldId: 'city',
    value:"TEST"
  });

Please help me to resolve this issue.

Upvotes: 0

Views: 1909

Answers (1)

Avi
Avi

Reputation: 2069

var currentRecordata = currentRecord.get();

Here, currentRecordata is a ReadOnlyRecord i.e currentRecord.get() returns read only record, so you cannot make changes to it.

Also as you said, you are making changes in client script, which entry point (method) do you want to make the said changes? You can get record object in every entry point and this object can be used to read + write.

eg. if you are using pageInit, you get currentRecord in scriptContext which is passed by NetSuite itself and you don't have to use currentRecord.get();

Further if you want to make changes in view mode, you will have to use N/record module to load record, make changes and then save it.

Please check this for further clarifications about client-script entry points and CurrentRecord module.

Upvotes: 0

Related Questions