Posts

Showing posts from February, 2022

Salesforce Fact #336 | Make lightning datatable column editable conditionally

Image
Suppose we have a use case in LWC where we would like to enable editing a column in lightning datatable based on a toggle switch. We can implement that logic in JS. Attached are the screenshots.  

Salesorce Fact #335 | No impact of assigned Id in screen flow Create Records

Image
Do you know if by mistake we have the Id populated for the Sobject record, the Create Records element would run prefectly fine ignoring the assigned Id and would create a new record. Attached are the screenshots.

Salesforce Fact #334 | Id implicitly available in screen flow Create Records

Image
Do you know while using Create Records element in screen flow with Sobject record variable, once the record is inserted the Id value is implicitly available like what we have in apex. No need to do additional SOQL to fetch it. Attached are the screenshots. This is how it is in Apex: And this is how it in screen flow:

Salesforce Fact #333 | CASE efficiency in formula

Image
Do you know while using picklist field value with CASE statement in formula field, we do not need to use TEXT() or any other function to get the expected value. Other advantage of using CASE statement is that unlike IF statement we do not need to refer the same field multiple times in ISPICKVAL function to check for the values. This saves the character count on formula field. Also number of parentheses is also less in CASE statement which leads to easier debugging. In this example, we have a number formula field Score which populates a numeric value based on the type of the account. Attached are the screenshots of both the versions.

Salesforce Fact #332 | Make screen flow email input dynamically required

Image
Suppose we have a simple screen flow which is used to accept some basic user input. Now, if we want to make the email input required on ad-hoc basis, we can create a hierarchical custom settings with a checkbox to enable/disable the setting in user/profile/org level. Attached are the screenshots.

Salesforce Fact #331 | Cross object formula in trigger

Image
Cross object formula fields also work perfectly in before insert trigger.  Attached are the screenshots.

Salesforce Fact #330 | Another beauty of trigger

Image
If we try to assign the formula field value in before save record-triggered flow when the record is created or updated, it throws error. However, in case of trigger it works perfectly without any error. Attached are the screenshots.

Salesforce Fact #329 | Sobject record in map key

Image
Do you know we can keep Sobject record as key in map collection. If any of the attributes of the Sobject record is updated outside the map, the same gets updated in the map. In this example, we are fetching 3 accounts having non-blank rating and then populating in the map. Then, we are updating the name of the first account in the list and same gets updated in the map also. Attached are the screenshots.    

Salesforce Fact #328 | BR() function in formula

Image
We have a BR() function in Salesforce formula which can be used for inserting line breaks for string values. Suppose, we have a formula field where we are considering the AccountNumber, Type & Rating of account and showing the value of these 3 as each new line. Now, if any of the value is blank in the record, the line break should also be not shown corresponding to that value. We can achieve this with some condition checks. Attached are the screenshots. When all values are present     When Rating is blank When AccountNumber is blank  

Salesforce Fact #327 | Login history using screen flow

Image
We can create a screen flow to to show the login history to the users for specific date using Get Records, Text template, Loop and assignment elements. Attached are the screenshots.

Salesforce Fact #326 | Approval comment from email approval

Image
Do you know we can put approval comments from email approval option as well. When email approval response is enabled, users can take action on approval requests from email. The first line of the response is the action(Approve/Reject) and the second line is considered for comment. For more details, please check  https://help.salesforce.com/s/articleView?id=sf.approvals_email_parent.htm&type=5 Attached are the screenshots.

Salesforce Fact #325 | Record level security in duplicate rule

Image
While setting up duplicate rule, we have an option to specify the record level security. If we select Enforce sharing rules, the duplicate rule runs only on the records which are accessible to the user. If we select Bypass sharing rules, the duplicate rule runs for all the records irrespective of the user's access. However, if there is a duplicate record found which the user cannot access, the user is notified of the duplicate and the record is not displayed. In this example, we have a duplicate rule setup on Account which checks for duplicate account number. Now we are creating some account record as admin and some record as some other user who can only access the records owned by him/her.  When we are selecting the enforce sharing rules option, the user is able to save a record with an already existing value of account number since all the records are not considered for duplicate check. But when we are selecting the Bypass sharing rules option, it is checking all the records and

Salesforce Fact #324 | Custom logout URL

Image
Do you know we can set a custom logout page in Salesforce. By default, we get to see the login.salesforce.com or the custom My Domain page on logging out from org. But there is an option to specify the Logout URL under Session Settings. Attached is the screenshot.