Posts

Salesforce Fact #931 | Performing aggregation using transform element

Image
We can perform aggregation operations as well using the transform element in flow. For this, we need to create an apex class with the AuraEnabled variables to store the aggregated value and refer the same in the transform element. This avoids the need for using loop. In this example, we are getting the sum of number of employees across all the accounts. Attached are the screenshots. Reference:  https://help.salesforce.com/s/articleView?id=platform.flow_build_logic_transform_sum_or_count.htm&type=5

Salesforce Fact #930 | Need to be careful while changing OWD to Public Read/Write

If we have used the share object of any custom object in apex or flow logic, we need to be careful while changing its OWD to Public Read/Write. While changing the OWD it won't show any reference error and trying to run the logic afterwards would show the below error: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: AccessLevel (trivial share level Read, for organization with default level Edit): [AccessLevel]

Salesforce Fact #929 | Nth highest in screen flow

Image
We can find the Nth highest value in screen flow using Get Records with a bit of logic. For example, we want to find the Nth highest NumberOfEmployees value across all the accounts. The idea is to fetch the records and then run a check to iterate over the records as long as the temp variable value is less than N value. The temp variable is initialized to 1. In the assignment we would keep on removing the first record. At the end, we will pick the first record from the collection. Attached are the screenshots. Note: this is just a POC flow and the error handlings, best practices are not covered.

Salesforce Fact #928 | Default minimum enqueue delay

Do you know there is an org-wide setting to specify the default minimum delay for the enqueue jobs which do not have a delay parameter. From Setup -> Apex settings, we can go to the setting and put a value between 1 and 600 seconds i.e. 10 minutes maximum. This is not applicable to jobs enqueued using System.enqueue(queueable, delay) method. Reference:  https://help.salesforce.com/s/articleView?id=release-notes.rn_apex_orgWide_delayQueueable.htm&release=242&type=5

Salesforce Fact #927 | Overwrite apex code in developer console

Image
Have you seen this popup while saving an apex class? This is encountered when the apex class has already been saved from some other dev tool like vs code and you are overwriting those changes from the dev console. So, this popup works like a reminder before proceeding.

Salesforce Fact #926 | Close custom action popup in dispatcher console

In order to close the custom action modal from vf page in field service dispatcher console, we need to use parent.postMessage('closeLightbox','*'). Reference:  https://developer.salesforce.com/docs/atlas.en-us.field_service_dev.meta/field_service_dev/fsl_dev_code_samples_dispatcher.htm

Salesforce Fact #925 | Adding case team to case using apex

How to add predefined case team to a case using apex? We need to use CaseTeamTemplateRecord. Sample code: CaseTeamTemplateRecord rec = new CaseTeamTemplateRecord(); rec.ParentId = '500IS000009iUe7YAE'; // id of the case record rec.TeamTemplateId = '0B46F000000XZoMSAW'; // id of the caseteamtemplate, can be fetched from CaseTeamTemplate object insert rec; Reference:  https://developer.salesforce.com/docs/atlas.en-us.208.0.object_reference.meta/object_reference/sforce_api_objects_caseteamtemplaterecord.htm