How to create a customer with multiple subsidiaries using suitescript

Hi,

 

I’m trying to create a customer record  with multiple subsidiaries using a Restlet service. I’m able to run the code below on the debugger tool without any errors, but when I try to use the same code on a suitescript it returns the following error: You entered an invalid field value 3 to the following field: subsidiary”

const customerRecord = record.create({type: record.Type.CUSTOMER, isDynamic: true});
customerRecord.setValue({ fieldId: "isperson", value: "T" });

customerRecord.setValue({ fieldId: "firstname", value: "FirstName" });

customerRecord.setValue({ fieldId: "middlename", value: "null" });

customerRecord.setValue({ fieldId: "lastname", value: "LastName" });

customerRecord.setValue({ fieldId: "companyname", value: "" });

customerRecord.setValue({ fieldId: "entitystatus", value: "13" });

customerRecord.setValue({ fieldId: "subsidiary", value: "1" });

customerRecord.setValue({ fieldId: "email", value: "teste@teste.com" });
customerRecord.selectNewLine('submachine');

customerRecord.setCurrentSublistValue({ sublistId: 'submachine', fieldId: 'subsidiary', value: 3 });

customerRecord.commitLine({ sublistId: 'submachine' });
customerRecord.save();
Rookie Asked on August 17, 2020 in SuiteScript.
Add Comment
1 Answer(s)
Best answer

You’re headed in the right direction…

After creating the customer record, you’ll need to create customer-subsidiary relationships with each additional subsidiary. It is a separate record type in NetSuite (see record browser). Basically, all you’ll need are the customer ID and subsidiary ID. Once saved, it will show up in the subsidiaries subtab of the customer.

Rookie Answered on August 17, 2020.

It worked !

But why it works using the customer record on the script debugger? That’s odd.

Thanks anyway.

on August 17, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor