Posts

Showing posts from May, 2024

Salesforce Fact #847 | SOQL INCLUDES with collection

Image
While using SOQL INCLUDES operator with collection, it doesn't support bind expressions. So, the input collection is to be converted to string format and we need to use dynamic SOQL. Reference:  https://salesforce.stackexchange.com/questions/314035/using-collections-in-soql-includes Attached is one sample screenshot.

Salesforce Fact #846 | Detect field value change in LWC

Image
Suppose we have a use case where we need to detect the change of a particular field value and need to refresh the record detail page.  We can make use of LWC getRecord() and getFieldValue() functions to implement the same. In this example, we have a LWC which is added to the Lead record detail page which refreshes the page when there is a change on Title field value. Reference:  https://salesforce.stackexchange.com/questions/386377/how-to-track-change-on-an-account-field-in-lwc Attached is the screenshot.

Salesforce Fact #845 | Archived activity in Salesforce

Below are considered as archived activities in Salesforce: 1) Events that ended more than 365 days ago 2) Closed tasks due more than 365 days ago 3) Closed tasks created more than 365 days ago, with no due date If a task was created more than 365 days ago and got closed sometime earlier, let's say it would be archived tomorrow. Now, after tomorrow if the user edits task and put a new due date, that task gets unarchived and is considered for rearchival after 365 days from the new due date. The IsArchived flag denotes whether an activity is archived or not. Reference:  https://help.salesforce.com/s/articleView?id=sf.activities_archived.htm&type=5

Salesforce Fact #844 | Screen flow datatable and lightning record picker reactivity combo

Image
We have the new record picker component in LWC and that works perfectly as reactive in screen flow. Suppose, we have a datatable in screen flow which is displaying certain account records and once we select a row, we want to make use of the record picker to show only related contacts of the selected account for selection. In LWC, we make use of the getRecord() LDS function to set the filter value reactively based on each time the accountId is passed from screen flow to LWC. Attached are the screenshots.

Salesforce Fact #843 | Adding parent field in field section in lightning app builder

Image
With the latest release, we can now add the related parent fields in the field section in lightning app builder. But regarding the level of access, if the user does not have access to the related parent field, that is not visible which is different from the formula field. In case of formula field, the value shows up even if the user does not have access. In this example, we have a field section where we have added one field from the app builder as the parent record field and the other one is a formula field. Both are fetching the related account industry. When the field access is not there for the user, the data is visible only in the formula field. Attached are the screenshots.

Salesforce Fact #842 | Error while using custom metadata methods

Have you encountered the below error while accessing custom metadata records using built-in methods: system.typeexception: unsupported sobject type and/or version This is because the metadata type methods were introduced in API version 51. So, please update the API version of the apex class to v51 or higher to resolve this. Reference:  https://salesforce.stackexchange.com/questions/339818/custom-metadata-types-not-supported-in-apex-classes

Salesforce Fact #841 | Apply to Child Territories in territory assignment rule

Image
There is an option 'Apply to Child Territories' while setting up a territory assignment rule. Let's see how it works. Suppose we have two territories 'Test Territory2' and 'Test Territory4', Test Territory4 is the child of Test Territory2. We have setup two rules for each of the territory as below: 1) for territory2, Account Industry equals 'Agriculture', Apply to Child Territories option checked. 2) for Territory4, Account Type equals 'Prospect', Apply to child territories option unchecked. Now, if an account only meets the first criteria, it is assigned to territory2. If an account only meets the second criteria, it is assigned to no territory. If an account meets both the criteria, it is assigned to territory4. So, if the Apply to Child Territories checkbox is checked, the rule condition of the child territory is checked in conjunction with the rule condition of the parent territory. Attached are the screenshots.

Salesforce Fact #840 | Platform Event publish limit

Platform events configured with 'Publish Immediately' behavior are counted against a separate publishing limit of 150 EventBus.publish() calls. It can be checked by issuing a Limits. getPublishImmediateDML() method call. Whereas platform events which are configured with 'Publish After Commit' behavior are counted against the DML statement governor limit. It can be checked issuing a Limits.getDMLStatements() call. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_eventbus.htm#apex_System_eventbus_publish

Salesforce Fact #839 | MasterRecordId in merge

Image
There is a field 'MasterRecordId' present in Account, Contact, Lead and Case object which is used in the merge operation. During the merge operation, one master record and additionally upto two same sobject records can be specified. Once the merge is completed, the merge record is deleted and the MasterRecordId field is populated with the corresponding master record Id. Reference:  https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_account.htm Attached is a sample screenshot.

Salesforce Fact #838 | Database.querywithBinds() usage

With the new Database.querywithBinds() method, we can use bind variables as map of String, Object. It also supports multiple values, and even works with list of Sobject. Reference:  https://salesforce.stackexchange.com/questions/397098/dynamically-pass-bind-variables-to-a-soql-query-with-querywithbinds-method Below are the code samples: //works with list of String Map<String, object> bindVars = new Map<String, Object>(); bindVars.put('accNames', new List<String>{'Test Acc1', 'Test Acc2', 'Test Acc3'}); String query = 'SELECT Id, Name, Rating FROM Account WHERE Name IN :accNames'; List<Account> accList = Database.queryWithBinds(query, bindVars, AccessLevel.USER_MODE); //works with list of Sobject as well List<Account> accList1 = [SELECT Id FROM Account WHERE Id                           IN ('0016F00002RrZdsQAF', '0016F00002RrZdtQAF', '0016F00002RrZduQAF')]; Map<String, object> bindVars =

Salesforce Fact #837 | Address copy in screen flow

Image
In most of the forms we fill in, there is an option to copy the current address details to permanent address on selecting a checkbox. Why not implement the same in screen flow? Thanks to reactive components and a bit of formula logic. Attached are the screenshots.

Salesforce Fact #836 | UNDELETE_FAILED

Image
Similar to ENTITY_IS_DELETED error, if we attempt to undelete a record from recycle bin by mistake which has already been hard deleted, the following error is encountered: UNDELETE_FAILED. Attached is one sample screenshot.

Salesforce Fact #835 | Multiple TYPEOF in SOQL query

We can have multiple TYPEOF clause in SOQL query. Example: SELECT     TYPEOF What         WHEN Account THEN Phone         ELSE Name     END,     TYPEOF Who         WHEN Contact THEN Email         ELSE Phone     END  FROM Task