Technical Architect Journey

Salesforce has changed recently the path to get the Technical Architect certification. There was a huge gap between all the other certifications and the Technical Architect certification. Now, you can fill that gap getting the skills required to get there by achieving the new domain specialist certifications and┬ábecoming Application Architect and System Architect in order […]

Get code coverage using REST API query

Let’s suppose you need to find all the classes or triggers starting with “MY_” and having 0 lines covered. The REST API query we need would be as follows: /services/data/v29.0/tooling/query/q=SELECT+ApexClassOrTriggerId,+ApexClassOrTrigger.Name,+NumLinesCovered,+NumLinesUncovered +FROM+ApexCodeCoverageAggregate +++WHERE+NumLinesCovered+=+0+AND+NumLinesUncovered+!=+NULL +AND+ApexClassOrTrigger.Name+like+’MY_%25’+ORDER+BY+ApexClassOrTrigger.Name Obviously, it will return a JSON string with the classes and triggers which match the criteria. There are a lot of online […]

Retrieving blob objects from Azure with Apex

Maybe you need to retrieve blobs stored in Azure Storage Services and save them as Salesforce attachments. Let’s suppose we have an attachment base64 encoded stored as a blob in Azure. We could retrieve it with the following snippet: String blobName = ”; String urlQueue = ‘’ + blobName; string storageKey = ”; Datetime dt […]

CreatedDate in test classes

Finally Salesforce fills the gap and allows you to specify the createddate field within test classes. You only have to use the Test.setCreatedDate method introduced with Spring ’16. @isTest private class CreatedDateTest { static testMethod void test() { Contact c = new Contact(FirstName =’Marc’, LastName = ‘Benioff’); insert c; Test.setCreatedDate(c.Id, DateTime.newInstance(2016, 1, 26)); Test.startTest(); Contact […]

Manage UserTerritory table through REST API

UserTerritory is one of the few objects that don’t allow DML Operations. However, we can manage it through the REST API. We could assign a User to a Territory by using the following APEX code: HttpRequest req = new HttpRequest(); Http http = new Http(); String baseUrl = URL.getSalesforceBaseUrl().toExternalForm(); req.setEndpoint( baseUrl + ‘/services/data/v34.0/sobjects/UserTerritory/’); req.setHeader(‘Authorization’, ‘OAuth […]