• tekry
  • NEWBIE
  • 10 Points
  • Member since 2018
  • Consultant/Developer
  • Mav3rik

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
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:
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?


 
  • February 26, 2020
  • Like
  • 0
Hi All,
Winter 18 supports data loader for uploading customer inputs. 
https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_service_bots_dataloader.htm

However, I it does not include details on how (e.g. which salesforce object to use). Does anyone know or where to get that details?
  • December 06, 2018
  • Like
  • 0
Hi All,
Winter 18 supports data loader for uploading customer inputs. 
https://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_service_bots_dataloader.htm

However, I it does not include details on how (e.g. which salesforce object to use). Does anyone know or where to get that details?
  • December 06, 2018
  • Like
  • 0