Archives

Apex Comparator compare multiple object fields

Sorting a list of Analysis messages first by boolean and then integer. First we will order by condition and then order. All records where condition is true is will be on top in descending order on top followed by all false condition in descending order. SummaryAnalysisMessages object to sort Compare object by condition and then […]

Rate this:

Read More

Apex save class when scheduled > ‘This schedulable class has jobs pending or in progress’

How do I develop in a class that is referenced in a scheduled job?You will see the following error when you try to save this class: This schedulable class has jobs pending or in progress There is the workaround, what I did is create a Job scheduler so basically 1 scheduled class from where I […]

Rate this:

Read More

Generating an Email-to-Case thread id using Apex

How to generate Email-to-Case thread id inside template: Generate the thread Id Send customEmail and Add ThreadId Putting it all together

Rate this:

Read More

Apex callout PATCH to Heroku Controller workaround

Setup a method to send Aync call to Heroku, add ‘?_HttpMethod=PATCH’ to the path to notify Heroku it’s a patch request Spring controller checks the RequestParam _HttpMethod to see if it’s a POST or PATCH request

Rate this:

Read More

Apex Return Diff fields between records

Sometimes you want to determine what has changed between an existing record in the database and an update to the record. The diffRecord method will return all the fields that changed for a specific record. Compare the difference between to records and return changed fields Test that only changed fields are returned

Rate this:

Read More

Apex Compare two Records and Merge updated fields

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 […]

Rate this:

Read More

Apex One Endpoint to Rule them all

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 […]

Rate this:

Read More

Apex Convert String To Camel Case

Convert string to camelCase for one underscore Convert string to camelCase for multiple underscore To Camel Case Test Class

Rate this:

Read More

Catch Apex Callout Loop not Allowed

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 […]

Rate this:

Read More

Apex workaround for doing callout after DML

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 […]

Rate this:

Read More