Justin
05/06/2026, 7:16 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 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 issuesCeligo AI
05/06/2026, 7:16 PMAI generated answer (using internal Slack threads):Based on the conversations, it seems like you are encountering an issue with the
custentity_cclass field when trying to create a customer payment programmatically. This issue could be due to a number of reasons, but here are a few things you could try:
1. Check the field level permissions for the role you are using to run the script. Even though the field is not mandatory, if the role does not have permission to access the field, it could cause this error.
2. Try to use the internal id of the class instead of the name. Sometimes, NetSuite can behave unexpectedly when using names instead of internal ids.
3. Check if the field custentity_cclass is available and accessible in the context of the script. You can do this by logging the entire record and checking if the field is present.
4. Try to create a customer payment using SuiteTalk SOAP web services instead of REST. Some users have reported that they were able to bypass similar issues by using SOAP instead of REST.
5. Check if there are any workflows, scripts or SuiteCloud Plus processes that might be interfering with the creation of the customer payment.
6. Try to create the customer payment in a different environment (like your production account) to see if the issue is specific to your sandbox account.
Remember, the order of setting field values matters in SuiteScript, as it triggers events, sourcing, etc. So, try to follow the sequence from the UI form.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
05/06/2026, 7:17 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.839050353
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.837768674
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.831665099
Celigo AI
05/06/2026, 7:17 PMJustin
05/06/2026, 7:23 PMAaron McCausland
05/06/2026, 8:52 PMAaron McCausland
05/06/2026, 8:54 PMJustin
05/06/2026, 8:55 PMAaron McCausland
05/06/2026, 8:56 PMAaron McCausland
05/06/2026, 8:57 PMJustin
05/06/2026, 8:59 PMJustin
05/06/2026, 9:06 PM1. record.transform(invoice <invoice_id> -> customerpayment, dynamic mode)
2. setValue('customform', '<form_id>') <- priority
3. (undepfunds skipped — not in body)
4. setValue('autoapply', 'F') <- priority
5. setValue('memo', '<memo>') <- regular loop ┐
6. setValue('payment', <amount>) <- regular loop │ class lands somewhere
7. setValue('trandate', <date>) <- regular loop │ in this band, in
*. setValue('class', '1') <- regular loop ┘ Python dict order
8. (credit sublist applied)
9. (apply sublist applied)
10. setValue('externalid', '<external_id>')
11. save({ ignoreMandatoryFields: true })
In the UI class is autoselected but I tried it both explicitly setting it and not touching the field and neither works when creating the payment - same error either way. There is no customer or subsidiary because that is sourced from the invoice object from my understanding. I don't see anything in there that would be in the wrong order, does anything jump out to you?Aaron McCausland
05/06/2026, 9:10 PMJustin
05/06/2026, 9:12 PMAaron McCausland
05/06/2026, 9:12 PMJustin
05/06/2026, 9:12 PMAaron McCausland
05/06/2026, 9:12 PMJustin
05/06/2026, 9:13 PMAaron McCausland
05/06/2026, 9:19 PMAaron McCausland
05/06/2026, 9:22 PMAaron McCausland
05/06/2026, 9:29 PMAaron McCausland
05/06/2026, 9:50 PMAaron McCausland
05/06/2026, 10:01 PMJustin
05/07/2026, 12:41 AMJustin
05/11/2026, 6:51 PMAaron McCausland
05/13/2026, 3:45 PM