Discussions

Check out Oracle NetSuite upcoming events and conferences here
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
Update your Profile with your Support type to get your Support Type badge.
Discover NetSuite's potential! Join our webinars, learn from experts, and optimize your operations. Whether you're experienced or new, secure your spot today and stay ahead in NetSuite!
Share with colleagues and friends who could benefit from our webinars too!

How to Set External ID via Script?

edited Dec 23, 2022 6:48AM in Ask A Guru 9 comments

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:
Tagged:

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!

Leaderboard

Community Whiz

Quarter 1 (Jan-Mar 2024)

This Week's Leaders

This Month's Leaders

All Time Leaders