{"type":"error.SuiteScriptError","name":"USER_ERRO...
# suitescript
s
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "USER_ERROR",
  "message": "Please enter a payment amount or apply credits/deposits",
  "stack": [
    "anonymous(N/serverRecordService)",
    "beforeSubmit(/SuiteScripts/Quikr UE Customer Payment(Receipt).js:316)"
  ],
  "cause": {
    "type": "internal error",
    "code": "USER_ERROR",
    "details": "Please enter a payment amount or apply credits/deposits",
    "userEvent": "beforesubmit",
    "stackTrace": [
      "anonymous(N/serverRecordService)",
      "beforeSubmit(/SuiteScripts/Quikr UE Customer Payment(Receipt).js:316)"
    ],
    "notifyOff": false
  },
  "id": "",
  "notifyOff": false,
  "userFacing": false
}
b
what are you doing in your before submit. it looks like you are creating another record
a
@shadman Ashrafi I think you didn't set payment amount. select an invoice from the sublist or set the payment amount.
s
var paymentRecord = record.transform({ fromType: record.Type.INVOICE, fromId: invoiceId , toType: record.Type.CUSTOMER_PAYMENT, isDynamic: false, }); var creditLineNumber = paymentRecord.findSublistLineWithValue({ sublistId: 'credit', fieldId: 'internalid', value: newJourId }); var applyAmount = 0; if(creditLineNumber!=-1) { paymentRecord.setSublistValue({ sublistId: 'credit', fieldId: 'apply', line: creditLineNumber, value: true }); paymentRecord.setSublistValue({ sublistId: 'credit', fieldId: 'amount', line: creditLineNumber, value: tdsAmt }); applyAmount = paymentRecord.getSublistValue({ sublistId: 'credit', fieldId: 'due', line: creditLineNumber }); } var invoiceLineNumber = paymentRecord.findSublistLineWithValue({ sublistId: 'apply', fieldId: 'internalid', value: invoiceId }); if(invoiceLineNumber!=-1) { paymentRecord.setSublistValue({ sublistId: 'apply', fieldId: 'amount', line: invoiceLineNumber, value: applyAmount }); } log.debug(" applyAmount = ",applyAmount); log.debug(" invoiceLineNumber = ",invoiceLineNumber); log.debug(" creditLineNumber = ",creditLineNumber); log.debug(" tdsAmt = ",tdsAmt); var paymentRecordId = paymentRecord.save({ enableSourcing: true, ignoreMandatoryFields: true }); log.debug(" new paymentRecordId = ",paymentRecordId);
i am getting error on paymentRecord.save
i think i am missing something to set.
a
set isDynamic: true
j
yes, set isDynamic to true or set the paymentamount via script.
b
you may also want to share the amounts of the transactions involved. your error suggests that the credit is not larger than the invoice amount
s
var creditLineNumber = paymentRecord.findSublistLineWithValue({ sublistId: 'credit', fieldId: 'internalid', value: newJourId }); log.debug(" creditLineNumber = ",creditLineNumber);
i am getting creditLineNumber = -1
which is wrong
b
you might want to try creating the transaction in the ui first
make sure you use the same amounts and ids used in your script
s
i have created the journal in the script earlier before transforming the invoice to customer payment.
b
its a pain to debug an error that is specific to the amounts involved
share enough code for me to make the script in my account and i can help you debug
that should include code that determines the values for invoiceId, newJourId, and tdsAmt
s
i got it resolved.
Thanks for support.
116 Views