Salesforce Category

Apex DocumentLink Trigger to Share Documents to Community Contacts

Trigger to check if the custom object has the correct file shared to community user Test class to check that sharing is done correctly

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

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

Salesforce export metadata to csv

Exporting salesforce metadata to csv, iterate through SObject and fields and show Label, API Name, FLS, Custom/Standard field. Output

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 fflib_SObjectUnitOfWork SimpleDML UNABLE_TO_LOCK_ROW nested try catch

UNABLE_TO_LOCK_ROW issue is very common if you have multiple users updating the record at the same time .Or say a batch job is running and is updating a record and same record another trigger or code snippet (usually a future method) is updating. A way to solve this is to retry multiple times to see […]

Rate this:

Read More

Apex Caching Performance Impact

Apex Caching is great for saving some basic Id’s of a user like his Account, Contact Id’s after he logs in so you don’t have to query for them. Reduces the amount of queries and improves speed. Caching is good for saving large blobs that don’t change frequently. Generic Cache Service to put, retrieve and […]

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