Hi all, I'm trying to set a customer subsidiary li...
# suitescript
d
Hi all, I'm trying to set a customer subsidiary line using the code below, but it is returning this error: "You entered an invalid field value 3 to the following field: subsidiary"
Copy code
function setSubsidiaries(customerRecord, subsidiaries) {
      (subsidiaries || []).forEach(function (subsidiary, id) {
        customerRecord.selectNewLine('submachine');
        customerRecord.setCurrentSublistValue({ sublistId: 'submachine', fieldId: 'subsidiary', value: subsidiary });
        customerRecord.commitLine({ sublistId: 'submachine' });
        _log.audit({ title: 'MultiSubsidiárias', details: 'Subsidiária ' + JSON.stringify(subsidiary)});
      });
    }
    setSubsidiaries(customerRecord, [1, 3]);
I am sure that there is a subsidiary with the id 3. When I try to edit an existing record this code works! Thanks for the help
s
Have you tried making them strings instead of numbers?
d
I tried both
It should work right? Or I'm doing something wrong?
Ok, last try. So far I noticed that it works on script debugger but it won't work if used on a Restlet
c
What's the role of the authenticated user accessing the RESTlet?
d
The user is an Administrator
I've got the answer from the forum: I had to create a "customer-subsidiary relationship" record using the customer and the subsidiary. After creating this record the subsidiary is displayed on the subsidiaries tab. Funny that the code works on the debugger but not on the restlet script.
👍 1