Posts

Showing posts from April, 2024

Salesforce Fact #834 | AccountId field on Task and Event

There is a field called 'AccountId' in Task and Event object. This field holds the related AccountId automatically whenever the WhatId is an Id from any of the below objects: Account Opportunity Contract Custom object that is a child of account When the WhoId is a ContactId and WhatId is any other object, in that case it stores the related AccountId of the contact. In all other cases, the AccountId is null. Reference:  https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_task.htm

Salesforce Fact #833 | SOQL LIKE operator limitation on picklist values

Image
We need to be careful while using the SOQL LIKE operator on picklist values. While using LIKE operator, it considers the translated label instead of the API name of that value. In this example, we have added the translation for the account industry 'Banking' for french language. Now, when the user language is english the LIKE operator works as expected but when the user language is french, the SOQL query does not return any result. Reference:  https://salesforce.stackexchange.com/questions/285076/why-does-the-like-soql-operator-implicitly-translate-picklist-values Attached are the screenshots.

Salesforce Fact #832 | Screen flow: using Transform element result in datatable

Image
In Screen flow, we can now use the Transform(Beta) element. We can use the result of the transform element in the standard screen flow datatable. In this example, we have fetched few account records and showing those records in the datatable after doing some manipulation. Couple of things to observe, 1) While trying to map in a sobject collection variable, the Id field is not available. 2) We have used BLANKVALUE() function on the account number, to show 'NOT AVAILABLE' when the account number is blank. 3) The TEXT() function is automatically added when mapping the picklist field values. It happened with the Industry and Rating fields. Attached are the screenshots.

Salesforce Fact #831 | Refresh utility bar lightning component on tab change

Image
While using any lightning component in the utility bar, it does not get refreshed whenever we change the tabs. However, we can make use of aura:locationChange to detect any change in the url and add logic accordingly. Reference:  https://developer.salesforce.com/docs/component-library/bundle/aura:locationChange/documentation In this simple example, we are just printing the current time every time the tab is changed to show that it is a different value each time. Attached are the screenshots.

Salesforce Fact #830 | Making field readonly after record creation using field section

Image
Suppose we want to keep a field editable only during the record creation, and once record is created it should be read only in the UI level(for non-admin users). Apart from validation rule, we can make use of field section in lightning app builder to implement the same. In this example, the LeadSource field on opportunity is made read only once it is created by keeping two field instances with two different filters. Note: Field section does not work for community. Attached are the screenshots.

Salesforce Fact #829 | Lead and Contact intelligent views

Intelligence views are available for Leads and Contacts in Sales cloud. It is a one stop place for all the engagement activity and insights of the records. In order to enable it, go to Setup -> Lead Intelligence View Setup / Contact Intelligence View Setup -> Turn the setting on -> Add the Intelligence View Button in the list view button layout. Reference:  https://help.salesforce.com/s/articleView?id=sf.leads_intelligence_view.htm&type=5    https://help.salesforce.com/s/articleView?id=sf.contacts_intelligence_view.htm&type=5

Salesforce Fact #828 | Reset value of LWC record picker using lwc:ref

Image
In LWC, if there are multiple lightning record pickers present and suppose we need to set/reset the value of a particular one, we can make use of the lwc:ref option. Attached are the screenshots.

Salesforce Fact #827 | Adding object in middle in LWC array of objects

Image
In LWC, Many times we deal with the scenario of adding an object conditionally in JS array of objects. And it needs to be added in the middle based on some condition. In this case the spread operator and the ternary operator combo works together. Reference:  https://stackoverflow.com/questions/70385371/js-conditionally-adding-adding-in-the-middle-of-an-array Attached is an example screenshot.

Salesforce Fact #826 | Disable toggle in screen flow

Image
Suppose we have a use case where we have a toggle in the screen flow and we want to allow the user to activate it only once. Once activated it will be disabled. We can use the toggle's value in Disabled attribute in this case. Attached are the screenshots.