On Suitescript transforming an Invoice Record to C...
# ask-stanley-ai
j
On Suitescript transforming an Invoice Record to Customer Payment should auto apply the payment to the Invoice?
c
AI generated answer (using internal Slack threads):
Based on the conversations, when transforming an Invoice Record to a Customer Payment in SuiteScript, it should auto apply the payment to the Invoice. This can be done using the
record.transform(options)
method. This method is used to transform a record from one type to another, in this case from an Invoice to a Customer Payment. However, it's important to note that there might be a performance issue when applying a payment to a specific invoice for a customer with a large number of open invoices. This is because both
record.create
and
record.transform
methods try to load all open invoices into the
apply
sublist, which can hit the governance limit if the number of invoices is too large. A workaround for this issue is to limit the apply sublist to only the records specified by setting the
defaultValues
option when creating the record. Here is an example:
Copy code
javascript
record.create({
  type: record.Type.VENDOR_PAYMENT,
  defaultValues: {
    vendorbills: "11111,22222"
  }
});
In this example, the
vendorbills
option is set to the internal IDs of the invoices that you want to apply the payment to. This will limit the apply sublist to only these invoices, avoiding the governance limit issue. ****** 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.865661681
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.861877441
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.842102051
Please provide your feedback on this answer.