This topic contains 2 replies, has 0 voices, and was last updated by charoldson 7 years, 1 month ago.

  • Author
    Posts
  • #18244

    northern_brewer

    I’m having a problem setting dates in a 2.0 User Event Script.

    I have a custom date field on a Sales Order and I need to set the date. Here’s a simple code snippet:

    must_ship = Date(’10/04/2017′);

    orderRecord.setValue({

    fieldId: ‘custbody_must_ship_date’,

    value: must_ship

    });

    The error returned is “The field custbody_must_ship_date contained more than the maximum number ( 10 ) of characters allowed.”

    This error leads me to believe I should be sending a string. 10 characters holds a date perfectly. However, If I try setting a string instead of a Date object, I get this error: “You have entered an Invalid Field Value 10/04/2017 for the following field: custbody_must_ship_date”

    I have tried every reasonable date format you can imagine… 10-04-2017, 2017-10-04, 2017/10/04, etc.

    What am I missing? Thanks for any help!
    This is a cached copy. Click here to see the original post.

  • #18245

    MChammaTX

    I assume the field type is date.

    From your code it looks like you are missing the keyword new

    Code:
    must_ship = new Date(’10/04/2017′);

  • #18246

    charoldson

    In SS1.0, we had nlapiDateToString and nlapiStringToDate. In SS2.0, we have the “format” module… format.format and format.parse.

You must be logged in to reply to this topic.