Justin
05/06/2026, 7:26 PMINVALID_KEY_OR_REF
Invalid class reference key ERROR: Field 'entity.custentity_cclass.id' Not Found for subsidiary 2.
whenever I try to programmatically create a payment in a sandbox environment. I have tried 3 completely different ways to make the payment and all caused the same exact error:
+---+---------------------------------------+----------------------------------------------------------------------------------+
| # | Entry point | Request |
+---+---------------------------------------+----------------------------------------------------------------------------------+
| 1 | SuiteTalk REST, direct create | POST /services/rest/record/v1/customerpayment with a JSON body |
| 2 | SuiteTalk REST, transform | POST /services/rest/record/v1/invoice/{id}/!transform/customerpayment |
| 3 | SuiteScript 2.1 RESTlet using | Server-side, our own code, isDynamic: true, ignoreMandatoryFields: true |
| | record.transform() + record.save() | |
+---+---------------------------------------+----------------------------------------------------------------------------------+
When I manually create the payment in the UI it works with no issues. For the setup I confirmed all of this:
• OneWorld account, I'm creating the payment in subsidiary 2.
• Customer record has a custom entity field custentity_cclass (List/Record → Classification). It's a custom field, not the default class field on the customer.
• The custom entity field has nothing configured under "Validation & Defaulting" or "Sourcing & Filtering" — both tabs are empty. No default value, no formula, no source list/source from, no filtering criteria.
• The customer's custentity_cclass value is 1 ("Retail & Distributor Sales").
• Class id 1 is valid, active, assigned to subsidiary 2, and has the "Include Children" checkbox checked on its subsidiary assignment.
• Manually creating/saving a Customer Payment in the UI for this customer with the class set succeeds.
• Everything is set to active - the class, the subsidiary, the customer, etc
I have tried all of these ideas so far but none of them work:
1. ignoreMandatoryFields: true on record.save(). No effect.
2. enableSourcing: false — confirmed not applicable, docs say it's standard-mode only and we use isDynamic: true.
3. Explicitly setting class to '1' on the payment before save. Same error.
4. Different class assignment. Tried with a different class that's directly assigned to a child subsidiary of 2 (rather than relying on "Include Children" inheritance from 2). Same error. So the failure isn't sensitive to whether the class is inherited via the parent or assigned directly to the child.
5. Two different customform ids — both the bundle's default form and the customer's own form (the one the UI uses on a successful save). Same error on both.
6. UI parity check. Captured the actual form POST the UI sends on a successful save. Identical customer, subsidiary, class, undepfunds, payment, trandate. UI: success. Same fields via SuiteScript: failure.
7. Logged the assembled payment record before save() — subsidiary=2, class=1, entity=<customer id>, custentity_cclass=1 on the customer. Nothing obviously wrong.
8. Debugger. Can't use the SuiteScript Debugger — no role in the account has both Debug Scripts and Customer Payments permissions.
Does anyone have any ideas whatsoever on anything else I can try? Or any ideas about what might be going on? I am super stuck and confused about how 3 completely different ways of programmatically creating the payment failed but the same exact payment can be created in the UI with no issuesEric B
05/06/2026, 7:38 PMJustin
05/06/2026, 7:38 PMJustin
05/06/2026, 7:57 PMInvalid class reference key ERROR: Field 'entity.custentity_cclass.id' Not Found for subsidiary 2. Do you have any other thoughts on things I could try by any chance? Or insights into what might be going on? That custom field is only on customers according to its config and I triple checked that the customer I am using has it set to a real class object with Include Children checked.
Thank you so much for your time!battk
05/06/2026, 8:51 PMJustin
05/06/2026, 8:52 PMbattk
05/06/2026, 8:53 PMJustin
05/06/2026, 8:57 PMcustentity_cclass as part of the payment (or at any point). Maybe a script is somewhere that I missed? Will double checkTomiecisco
05/06/2026, 9:00 PMYvonne
05/07/2026, 12:39 PMJustin
05/07/2026, 2:15 PMJay Flynn09
05/07/2026, 5:38 PMJustin
05/07/2026, 9:25 PMJustin
05/11/2026, 6:51 PM