I'm trying to create a payment from an invoice in ...
# ask-stanley-ai
l
I'm trying to create a payment from an invoice in a suitescript, I'm iterating thru the "apply" and "credit" sublists to apply the amounts, but when I save the record, in the afterSubmit phase, the credit sublist is nowhere to be found. I already tried saving the record enabiling sourcing and ignoring mandatory fields.
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you're facing an issue with accessing the 'credit' sublist in the afterSubmit phase of your SuiteScript. This sublist is only available on view or create, and it's not accessible in the afterSubmit phase. If you're trying to get it for an existing payment, there is only view, which is really hard to get outside of a payment viewed in the UI on the beforeLoad. One workaround could be to use a saved search to get the credits applied to the invoice of the customer payment. However, this might not be suitable if you have to deal with invoices with multiple payments/refunds. Another approach could be to use
record.transform(options)
directly from invoice to customer payment. This seems to be the most straightforward approach according to one of the conversations. Remember, if you're dealing with journals instead of invoices or credits, you might need to look at the applied to transaction on the journal. It's applied to the invoice or whatever other transaction it's applied to, not the customer payment. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.864105523
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.863060832
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.862054586
Please provide your feedback on this answer.