can the Account field on a customer refund record ...
# ask-stanley-ai
a
can the Account field on a customer refund record be set via script? Should it be set on create or after submit?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it appears that the Account field on a Customer Refund record can indeed be set via script. However, it's important to note that the order of fields matters when using dynamic mode, as later fields like payment method can overwrite the Account field. Here's a sample code snippet that was shared in the conversation:
Copy code
javascript
// creating a refund record
let refundRecord = record.create({
  type: record.Type.CUSTOMER_REFUND,
  isDynamic: true
});

// setting the values on the refund record
refundRecord.setValue({
  fieldId: SCRIPTIDS.customerFieldId,
  value: refundData.customerId,
  ignoreFieldChange: true
});

// todo make account on refund = #116 (Undeposited Funds - System Generated)
refundRecord.setValue({
  fieldId: 'account',
  value: 116, // this account isn't setting correctly when the record is saved.
  ignoreFieldChange: true
});
However, it was suggested that using
record.transform
could be a more efficient approach, as it would automatically apply the refund to the indicated payment. As for when to set the Account field, it seems that it should be set on create. However, it was also mentioned that you might want to avoid after submit scripts that modify the current record, as they can impact performance by requiring the record to be saved again. ****** 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.852948666
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.843006849
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840936422
Please provide your feedback on this answer.