OK, here's a head-scratcher. Trying to set the li...
# suitescript
j
OK, here's a head-scratcher. Trying to set the line-level Expected Receipt Date on a Purchase Order in a scheduled script. I've tried formatting a date object, hardcoding in formats like MM/DD/YYYY and M/D/YYYY. In every case I get the error
Copy code
The field expectedreceiptdate contained more than the maximum number ( 5 ) of characters allowed.
What am I missing here? Why would Expected Receipt Date only allow 5 characters? I even log before I set the field to make sure I don't have my value incorrectly defined somewhere or something like that. Nonetheless, I am confused. Any ideas?
s
I had a similar issue the other day, trying using the
N/format
module, specifically
format.format
and
format.parse
on your data. One of them will set properly and one will not, I belive
format.parse
is what you need here.
j
This is what I had tried initially_`format.format({ type: format.Type.DATE, value: new Date() })`_
u
Are you doing it over a server side script? if yes, try to first create the record in UI, load the record in the script debugger in the record mode that you are using on your script and the the value of the field and compare it first with the result of format.format.
j
Crazy interesting... changed to setSublistText () rather than setSublistValue() and it works.
Copy code
dateValue = format.format({ type: format.Type.DATE, value: new Date() });
po.setSublistText({
  sublistId: "item",
  fieldId: "expectedreceiptdate",
  line: i,
  text: dateValue
});
b
the general advice is use a Date with setValue and setText with a string