Hello everyone, how can I assign a "paymentoption"...
# suitescript
a
Hello everyone, how can I assign a "paymentoption" in a "customerpayment" via script? i have this:
var objRecord3 = record.transform({
fromType: 'invoice',
fromId: invoiceIdP,
toType: 'customerpayment'
});
objRecord3.setValue({
fieldId: 'trandate',
value: defaultDate
});
objRecord3.setValue({
fieldId: 'paymentoption',
value: 15
});
var rid3 = objRecord3.save();
but obtain this error:
{"type":"error.SuiteScriptError","name":"INVALID_FLD_VALUE","message":"You have entered an Invalid Field Value 15 for the following field: paymentoption","id":"","stack":["Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at Object.onRequest (/SuiteScripts/DT-009 - /SD_SL_EmailPa.js:449:55)"],"cause":{"type":"internal error","code":"INVALID_FLD_VALUE","details":"You have entered an Invalid Field Value 15 for the following field: paymentoption","userEvent":null,"stackTrace":["Error\n at RecordInvoker.save (suitescript/resources/javascript/record/serverRecordService.js:371:13)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at Object.onRequest (/SuiteScripts/DT-009 - Card/SD_SL_EmailPa.js:449:55)"],"notifyOff":false},"notifyOff":false,"userFacing":true}
b
thats basically it, though people tend to prefer strings for the value instead of numbers to prevent suitescript from stringifying it wrong
your error suggests that the payment option with the id of 15 is not a valid choice
the usual is to make the same customer payment in the ui and take a look at the available payment options and then choose one thats actually valid
the less visual way of doing this is using Field.getSelectOptions
the final warning is that payment options and payment methods are not the same thing
do not use the internal id of a payment method and expect it to translate to a payment option
🙏 1