简体   繁体   中英

NetSuite SuiteScript 2.0 - setValue Date Issue

Can't seem to get my Date type field to accept my new date value. It doesn't throw any errors; it just appears to ignore the setValue function. If I set the date in the UI, a script log will show the following format:

{"details": datetypeField = Thu Oct 25 2018 00:00:00 GMT-0700 (PDT)"}

Any help would be greatly appreciated.

/**
 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */

define(["N/record", "N/format"], function(r, f) {
    var customer = r.load({
        type: r.Type.CUSTOMER, 
        id: "111",
        isDynamic: false,
    }); 

    var today = new Date();  

    customer.setValue({
        fieldId: "custentity_datetypefield",
        value: today
    }); 

    customer.save({
        enableSourcing: true,
        ignoreMandatoryFields: false
    });
});

It looks like that module is a User Event script, but its code isn't connected to any event trigger; I would expect to see a beforeSubmit or afterSubmit handler wired up in the output of the module. I would also expect that this file would fail to upload when trying to create the Script record.

How are your Script and Deployment records set up? How are you expecting to trigger this code?

You are setting the field correctly; Date fields expect a Date Object in the value property, so that much is definitely correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM