<#C29HQS63G|> Hi Netsuite Professionals I am new h...
# suitescript
m
#C29HQS63G Hi Netsuite Professionals I am new here and I am entry level netsuite developer and I have question reagarding suitescript I am trying to create one Customerpayment from multiple invoices in suitescript 2 but it throws error "An unexpected SuiteScript error has occurred" Here is my Suitescript try { var invoiceId = 703778; // ID of the invoice for which payment is being made var paymentMethod = "1"; // Payment method (e.g. 'creditcard') var invoiceTotal=130.22; // Handle form submission var customerId = 16568; var payment = record.create({ type: record.Type.CUSTOMER_PAYMENT, isDynamic: false }); payment.setValue({ fieldId: 'customer', value: customerId }); payment.setValue({ fieldId: 'autoapply', value: false }); payment.setValue({ fieldId: 'trandate', value: new Date() }); payment.setValue({ fieldId: 'paymentmethod', value: paymentMethod // 1 = Check payment method }); payment.setSublistValue({ sublistId: 'apply', fieldId: 'internalid', value: invoiceId, line:1 }); payment.setSublistValue({ sublistId: 'apply', fieldId: 'amount', value: invoiceTotal, line:1 }); var paymentId = payment.save(); return paymentId; } catch( e ) { log.debug( { 'title': 'error', 'details': e } ); return { 'error': { 'type': e.type, 'name': e.name, 'message': e.message } } }
b
practice creating the customer payment in the ui first
you will basically need to set the same fields on the customer payment that you would in the ui
m
thank you for reply, I traced logs and log says error at setSubListValue function, I am wonder why this setSubListValue is not supported
b
there are multiple errors that can occur in setSublistValue
you need to share more details from the error