Alternatively, what are the field IDs for the cred...
# suitescript
g
Alternatively, what are the field IDs for the credit sublist on the Accept Payment screen?
g
thank you!
✅ 1
Copy code
function afterSubmit(context) {
    if (context.type === "create" && context.newRecord.type === "customerpayment") {
      const creditsCount = context.newRecord.getLineCount({ sublistId: "credit" });
      log.debug({ title: "Credits Count", details: creditsCount });
      if (creditsCount > 0) {
        for (let i = 0; i < creditsCount; i++) {
          // If apply is false, continue
          if (context.newRecord.getSublistValue({ sublistId: "credit", fieldId: "apply", line: i }) === false) continue;

          // Load and save the customer payment record to force it to update its last modified date
          const paymentRec = record.load({ type: record.Type.CUSTOMER_PAYMENT, id: context.newRecord.getSublistValue({ sublistId: "credit", fieldId: "internalid", line: i }) });
          log.debug({ title: "Payment record saved?", details: paymentRec.save() });
        }
      }
    }
  }
Catches an edge case in our NS -> Celigo -> Salesforce integration where lastmodifieddate does not update if the payment is applied as a credit, so Celigo doesn't pick up the delta. >.<