#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 } }
}