Salesforce Category

Apex Coding Challenge for Iterating Lists

Here is the problem statement: Given an expectedSum value find the sum (n+ (n+1) = expectedValue) from a list that equals the expectedSum. I am using the following list 1,3,4,4,5,9 and looking for the sum to be 8 (3+5, 4+4) *Note the list is sorted Solution 1: The above time complexity for a nested for […]

Rate this:

Read More

Salesforce Object Level and Field Level Security Architecture

The Salesforce Security review require that both: Object Level (OLS) Field Level (FLS) Security is applied for the following areas: Query of data – Selectors Triggers – Domains DML – Unit of Work To check both (OLS) and FLS we can use fflib_SecurityUtils it has all the to methods to check if a user can access […]

Rate this:

Read More

Apex Interview Question > FizzBuzz

Consider the following problem: Write a short program that prints each number from 1 to 100 in one line For each multiple of 3, print “Fizz” instead of the number. For each multiple of 5, print “Buzz” instead of the number. For numbers which are multiples of both 3 and 5, print “FizzBuzz” instead of […]

Rate this:

Read More

Apex Test Active Case Assignment Rules Assertion Fails

If you are testing active assignment rules you need to add it as an DMLOptions during testing else your assignment rule(s) will not get called and your assertion(s) may fail. If you have one active Case Assignment Rule you can use dmlOpts.assignmentRuleHeader.useDefaultRule = true else you need to query for AssignmentRules. To query AssignmentRules you […]

Rate this:

Read More

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