I have an extremely simple User Event script that ...
# suitescript
a
I have an extremely simple User Event script that modifies a custom field using the before submit event.
Copy code
function beforeSubmit(context){
            const purchprice = context.newRecord.getValue('cost');
            const purchconversionrate = context.newRecord.getValue("purchaseconversionrate")
            const priceum = Math.round(purchprice / purchconversionrate)
            log.debug("priceum",priceum)
            context.newRecord.setValue({
                fieldId: "custitempriceperconsumptionum",
                value: priceum
            })
            log.debug("rec",context.newRecord)
      }
I can see it's running and the second log returns the record with the value set but the changes aren't being saved on the item.
s
Is there something about the definition of your field that is overwriting whatever you are doing here?
a
Ah. I had the field set to view only. My bad.