This topic contains 6 replies, has 0 voices, and was last updated by ACarter 7 years, 3 months ago.

  • Author
    Posts
  • #18313

    ACarter

    Hello,

    I am having an issue with SuiteScript 2.0 Map/Reduce script setting a date field. Error:

    “You have entered an Invalid Field Value 07/10/2017 for the following field: custbody_amb_invoice_start”

    In the UI, I can enter this date. In SuiteScript 1.0, this date works fine. But, in SuiteScript 2.0, the script returns an error. I have tried every form of date I can think of and nothing works, MM/DD/YYYY, DD/MM/YYYY, YYYY-MM-DD, date format, string format. I tried also creating a new custom field, as suggested above, but still the same error.

    Has anyone had luck with resolving this type of issue?

    Thanks,

    Anthony
    This is a cached copy. Click here to see the original post.

  • #18314

    david.smith

    Use the N/format to convert the value from string to date.

  • #18315

    ACarter

    Hi David,

    Thanks for the quick reply. I’ve tried this a few different ways and receive the same error.

    var formatDate = format.format({

    value: ’07/10/2017′,

    type: format.Type.DATE

    });

    log.debug(‘formatDate’, formatDate);

    This is the log: 07/10/2017

    recInv.setValue({

    fieldId: ‘custbody_amb_invoice_start’,

    value: formatDate

    });

    Error: You have entered an Invalid Field Value 07/10/2017 for the following field: custbody_amb_invoice_start

  • #18316

    david.smith

    What type of field is it? Date, Date/Time, etc??? Make sure you’re matching the correct type. Also, you might need to do a format.parse first and then format.format.

  • #18317

    ACarter

    The field type = Date. I’ve tried format.parse, format.format, the combination of both of them. Nothing seems to work. This is the combo of format.parse and format.format:

    var initialFormattedDateString = “07/28/2015”;

    var fpDate = format.parse({

    value: initialFormattedDateString,

    type: format.Type.DATE

    });

    var ffDate = format.format({

    value: fpDate,

    type: format.Type.DATE

    });

    recInv.setValue({

    fieldId: ‘custbody_amb_invoice_start’,

    value: ffDate

    });

    recInv.setValue({

    fieldId: ‘custbody_amb_invoice_end’,

    value: ffDate

    });

    This error is returned: You have entered an Invalid Field Value 7/28/2015 for the following field: custbody_amb_invoice_start

  • #18318

    TheUsualSuspect

    You put actual date objects into Date fields in 2.0 vs a string. This tripped me up at first. Put your string into a date constructor and it should work

  • #18319

    ACarter

    I tried this as well, but it didn’t work in non-dynamic mode. I worked with NetSuite Support to see if they had any ideas and they couldn’t think of anything that would get it to work in non-dynamic mode. We were able to get it to work in dynamic mode (isDynamic = true), by using Date objects as you guys have suggested. Most of our existing scripts are not in dynamic mode in SS 1.0, so when converting these over to 2.0, I’m unclear if there will be any issues.

    For now, it looks like the issue is semi-resolved. thanks for your help

You must be logged in to reply to this topic.