This topic contains 6 replies, has 0 voices, and was last updated by ACarter 7 years, 3 months ago.
-
AuthorPosts
-
August 4, 2017 at 10:27 am #18313
ACarterHello,
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. -
August 4, 2017 at 10:35 am #18314
david.smithUse the N/format to convert the value from string to date.
-
August 4, 2017 at 10:40 am #18315
ACarterHi 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
-
August 4, 2017 at 11:04 am #18316
david.smithWhat 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.
-
August 4, 2017 at 11:27 am #18317
ACarterThe 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
-
August 8, 2017 at 3:14 pm #18318
TheUsualSuspectYou 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
-
August 8, 2017 at 4:55 pm #18319
ACarterI 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
-
AuthorPosts
You must be logged in to reply to this topic.