Having trouble creating a `Customer Refund` record...
# suitescript
j
Having trouble creating a
Customer Refund
record with the correct
account
value set. Any idea what I’m doing wrong?
Copy code
// 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
});
b
not enough code shared
dynamic mode means the order of fields matters
and account is sourced, so laters fields like payment method will overwrite it
j
So, with dynamic mode I should try to replicate the actions I would take in the UI, correct?
I’ll read up on dynamic mode
appreciate the feedback
b
fair chance in this case the payment method is overriding the account
j
checking now, thanks
b
you may also want to consider using record.transform, which will automatically apply the refund to the indicated payment
👀 1
j
Thank you, this will save a ton of time.
Yep, I updated my function to include record.transform and I was able to remove most of those .setValue calls.. Much cleaner now.
Thank you @battk