Tuesday, March 13, 2018

External IDs and Http Mocks

Rest of the challenges for the "Apex Specialist" super badge were all right to handle. Relatively easier for me than challenge 1. Two key learning from my point of view:
1. In Salesforce you can use any field on the custom object to be used as an external ID. And, you can NOT set external id directly, i.e. code like MyObj__c.externalID = 'xyz'; does not work.
2. When testing a method that will make an http callout directly or indirectly, do not forget to set the mock class that implements HttpCalloutMock interface: Test.setMock(HttpCalloutMock.class, new MyCalloutMock());

No comments:

Post a Comment