I have orders generated from a Suitelet. In my UE ...
# suitescript
m
I have orders generated from a Suitelet. In my UE script, beforeSubmit - I am trying to load a customer record and set a value on it. This code runs, but the update to the Customer record never happens. What's wrong with this:
Copy code
if (runtime.executionContext === runtime.ContextType.SUITELET) {
                if (customerDeliveryNumber && !orderDeliveryNumber) {
                    SALESORDER.setValue({
                        fieldId: 'custbody_delnotifmobphonenum',
                        value: customerDeliveryNumber
                    });
                }
                if (orderDeliveryNumber && orderDeliveryNumber !== customerDeliveryNumber) {
                    _CUSTOMER.setValue({
                        fieldId: 'custentity_delnotifmobphonenum',
                        value: customerDeliveryNumber
                    });
                }
                try {
                    _CUSTOMER.save();
                } catch (e) {
                    log.debug({title: e.title, details: e.details});
                }
            }
        }
r
can you put a log statement after each if condition and see till which if condition your code is getting executed, you will have to share the complete script.
m
I did have the log statements but removed them to make the snippet short. The Sales Order updates are fine. The second condition does get triggered and everything runs, but no update on the customer record.
r
can you put x=_CUSTOMER.save() and log x, and see if you are getting the customer record internal id. Also if you can provide full script, might be able to help out, don't see anything out of the ordinary here..
👍 1
m
I see my issue - dumb error. It's actually getting set but with the same value as what is already there. Using wrong field. logging the _CUSTOMER.save() allowed me to spot that so thanks for the tips!