Skip to content

Instantly share code, notes, and snippets.

@nicolasmelo1
Created January 10, 2024 17:53
Show Gist options
  • Save nicolasmelo1/eaf6d126d3b91e67d0c9bbc5110c0560 to your computer and use it in GitHub Desktop.
Save nicolasmelo1/eaf6d126d3b91e67d0c9bbc5110c0560 to your computer and use it in GitHub Desktop.
var customerRefund = nlapiCreateRecord('customerrefund');
customerRefund.setFieldValue('customer', '111736');
customerRefund.setFieldValue('currency', '1');
customerRefund.setFieldValue('account', '217');
customerRefund.setFieldValue('trandate', new Date());
customerRefund.setFieldValue('paymentmethod', '14');
const creditCount = customerRefund.getLineItemCount('apply');
const creditMemoIndex = customerRefund.findLineItemValue('apply', 'internalid', '4498596');
console.log(creditMemoIndex)
for (let record = 1; record <= creditCount; record++) {
if (customerRefund.getLineItemValue('apply', 'internalid', record) == '4498596') {
customerRefund.selectLineItem('apply', record);
customerRefund.setCurrentLineItemValue('apply', 'apply', 'T');
customerRefund.commitLineItem('apply');
break;
}
}
var customerRefundId = nlapiSubmitRecord(customerRefund, false, true);
console.log(customerRefundId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment