Hi Everyone, I'm trying to set the expiry date in ...
# suitescript
s
Hi Everyone, I'm trying to set the expiry date in credit card detalis sublist under customer record, but getting the issue. Can anyone help me with this,
n
Try to set it manually in the UI.
s
it's setting
b
the usual is to load an existing record with the field set
and use getValue or getText to see how its set
be sure to use the matching setValue and setText
when you are setting
e
It should be in mm/yyyy format.
s
I'm setting like mm/yyyy format only.
I'm trying setting in credit card line in the customer record
var exp_date=exp_month+'/'+exp_year; var formattedDateString = format.parse({ value: exp_date, type: format.Type.MMYYDATE }); student_rec1.setCurrentSublistText({ sublistId: 'creditcards', fieldId: 'ccexpiredate', value: formattedDateString, ignoreFieldChange: true });
b
that looks like an attempt trying to mix up the types
setValue and setText accept different data types on the more complicated field types
use getValue and getText to see which data types go in each
and set with a matching data type
s
ok,let me try
but, that is sublist field
b
there are sublist equivalents
s
i got the object {"id":"ccexpiredate","label":"Expiration Date","type":"mmyydate"}
b
you want the value or text
the field type doessnt really help you unless you already know what goes in mmyydate fields
s
i want to set the value
b
thats not what your code does
it tries to set the text
s
same issue getting for value also
b
what issue are you facing for getting the value?
s
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "USER_ERROR",
  "message": "Please enter a valid expiration date",
  "stack": [
    "anonymous(N/serverRecordService)",
    "createtionofEnrollPaymentRecord(/SuiteScripts/CreationofEnrollPaymentRecord_SL.js:632)"
  ],
  "cause": {
    "type": "internal error",
    "code": "USER_ERROR",
    "details": "Please enter a valid expiration date",
    "userEvent": null,
    "stackTrace": [
      "anonymous(N/serverRecordService)",
      "createtionofEnrollPaymentRecord(/SuiteScripts/CreationofEnrollPaymentRecord_SL.js:632)"
    ],
    "notifyOff": false
  },
  "id": "",
  "notifyOff": false,
  "userFacing": false
}
b
and which line of code is causing this?
s
"2022-02-01T080000.000Z" this date I'm trying to setting after parsing var formattedDateString = format.parse({ value: exp_date, type: format.Type.MMYYDATE });
b
thats not a line that can throw an error
nor is it an attempt at getting the value
im telling you that you are getting the types of the value and text wrong
get the value or text of a record that already has that field filled in
so you can see what valid values look like
s
no I'm not getting any values,trying to setting
b
and im telling you that your data types are wrong
and that you should get an existing value to see how you are wrong
s
yes, but how to format my value to that type
b
get an existing value to find out
s
'01/2023' this format I'm getting
b
using getValue or getText?
s
getSublistValue()
b
what did your actual logging code look like