SuiteScript Change On Credit Hold Field On Customer Record

How do you change the Hold field found on the customer record using SuiteScript?

The Hold field in a Customer record prevents users or the customer from having any new Sales Orders being placed and has three settings On , Off and Auto . The code name of the field is creditholdoverride .

To set the value for this field using SuiteScript, enter the value in all capital letters according to the value you want.

For example upon loading the Customer record:

const r = record.load({type: record.Type.CUSTOMER, id: 0});
r.setValue({fieldId: "creditholdoverride", value: "AUTO"});

If you enter Auto with just the first letter containing a capital, the entry will not work. Even trying an ID number does not work.

The way I was able to find what type of value was needed was by appending &xml=T to a Customer record view and inspecting the XML document where creditholdoverride was set, and this was what I found for a Customer whose status was Auto :

...
<creditholdoverride>AUTO</creditholdoverride>
...

As you can see, the XML view of the Customer record had the value in all capital letters, but the view of the Customer record contained only Auto .

Summary

To change the creditholdoverride value using Suitescript set the value accordingly by using the capitalized version of the value, i.e. AUTO , ON or OFF .