Hi There
I am trying to set the external ID value on a customer record using a userevent script.
I have tried with different entry points--before submit and after record submit.
There is no error message though the external id is not being updated either.
this is the script:
/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define(["N/record"], function (record) {
/**
* @param {UserEventContext.beforeSubmit} context
*/
function beforeSubmit(context) {
var customer = context.newRecord
var customerId = customer.getValue({ fieldId: "entityid" })
var id = customer.id
log.debug("id", id)
var externalId=customer.setValue("externalid", customerId)
// customerNew.save()
log.debug("customerNew", externalId)
}
/**
* @param {UserEventContext.afterSubmit} context
*/
function afterSubmit(context) {
var customer = context.newRecord
var customerId = customer.getValue({ fieldId: "entityid" })
var id = customer.id
log.debug("id", id)
var externalId=customer.setValue("externalid", customerId)
// customerNew.save()
log.debug("customerNew", externalId)
}
return {
// beforeLoad: beforeLoad,
beforeSubmit: beforeSubmit,
afterSubmit: afterSubmit,
}
})
am I using the correct method to set the field value?
thanks