Posted on May 31, 2017 Leave a Comment
When you have two record, one being the existing queried record and the other the updated record. To merge the original with the updated field without committing the changes you can iterate the current record’s fields and check which of the fields changed. Update the changed fields to the new updated fields value. Now we […]
Posted on May 15, 2017 Leave a Comment
Most systems need to do CRUD on some objects and also query some information. Why not have one endpoint to do it all?I have created a endpoint that can do all that using mapping between systems field and Salesforce fields. System field does not contain any underscores or Salesforce specific syntax like (__c). With that […]
Posted on May 1, 2017 Leave a Comment
Convert string to camelCase for one underscore Convert string to camelCase for multiple underscore To Camel Case Test Class
Posted on April 3, 2017 Leave a Comment
Getting the following error: Apex Callout Loop not Allowed when you are doing a callout to the same Salesforce org and then calling out to another external service. In this case I was doing a callout to the same salesforce org and then doing a callout to the my logging service. Further you can write […]
Posted on March 14, 2017 Leave a Comment
If you are trying to do a callout after a DML operation you would have seen this error message: You have uncommitted work pending. Please commit or rollback before calling out A way around doing callouts after a DML is to do the DML as its own internal callout. This is possible by creating a […]
Posted on March 10, 2017 Leave a Comment
Sorting objects generic class Compare Strings Compare Dates Test Class
Posted on March 3, 2017 Leave a Comment
Apex class to lookup record types and cache them Test Class
Posted on February 28, 2017 Leave a Comment
Checking if a user has a valid session before making a query or call else an INVALID_SESSION error will be returned. The value of time remaining for the session can be cached and referenced so this query only runs a few times. Every time a user makes a request we can check the cache and […]
Posted on February 22, 2017 Leave a Comment
Define the Error messages detail in json format as static resource Define a ResponseCode class to parse the json into a List of ResponseCodes Define a ResponseCode Manager to translate the Codes into a map to get by id Catch exceptions and log exceptions to logging provide
Posted on February 21, 2017 1 Comment
When doing a callout it has to happen before the DML action. If it happens after the DML it will throw an error or will not execute. Workaround I used is to manually keep track of the mock response, and call the respond method to intercept Http.send when running a test. By checking for Test.isRunningTest() […]