You need to sign in to do that
Don't have an account?
tekry
Populate case lookup field using CaseNumber using REST API
I have an custom object MyObject__c with a custom lookup field to Case, Case__c.
I used Postman to create a new record through REST API that populates Case__c field from an existing Case record.
I used the following:
I tried similar approach in Apex:
ERROR running force:apex:execute: Line: 2, Column: 12
Field is not writeable: Case.CaseNumber
Questions:
1) I understand that Apex code does not work because CaseNumber is not an external Id. However, why is the REST API working?
2) Is there Salesforce documentation for this behaviour in REST API?
I used Postman to create a new record through REST API that populates Case__c field from an existing Case record.
I used the following:
Resource: /services/data/v40.0/sobjects/MyObject__c Method: POST Body: { "Case__r": { "CaseNumber": "00001014" } }Result: The MyObject__c record was created and Case__c field is populated with correct Case record Id.
I tried similar approach in Apex:
insert new MyObject__c ( Case__r = new Case (CaseNumber='00001014') );Result:
ERROR running force:apex:execute: Line: 2, Column: 12
Field is not writeable: Case.CaseNumber
Questions:
1) I understand that Apex code does not work because CaseNumber is not an external Id. However, why is the REST API working?
2) Is there Salesforce documentation for this behaviour in REST API?