Posts

Showing posts from October, 2023

Salesforce Fact #784 | Min Integer value in apex

How to use the min Integer value in apex? Suppose we need to use the minimum Integer value in apex. Now, the minimum value is - 2147483648. We get an error if we try to directly assign it to a variable. So, here's the workaround: Integer i = -2147483648;  // Illegal integer Integer i = -2147483647-1; //this works Reference: One of the problems on  https://www.apexsandbox.io/

Salesforce Fact #783 | add() method error

Image
While using the add() method to add element in a list at a particular index, we need to be careful. Unlike other programming languages, we will encounter error if the list is empty. Attached is the screenshot.

Salesforce Fact #782 | EMPTY_ID in group by

Image
While using GROUP BY in SOQL to find out the count of users corresponding to each role, for the blank role the developername is shown as 'EMPTY_ID'. Attached is the screenshot.

Salesforce Fact #781 | Showing formula field value in screen flow datatable

Image
We can show formula field values as well in screen flow datatable. Suppose we have a field in Lead which shows the lead rating in the form of stars and which is basically a formula(text) field using the IMAGE() function. The field value can be shown in datatable. Attached are the screenshots.

Salesforce Fact #780 | lightning map of selected record in screen flow datatable

Image
We use mapMarkers in LWC to show the map for an address. We can render the address map for the address of a selected record in screen flow datatable using a LWC. In this example, we are rendering the map for the shipping address of the selected account record considering the ShippingLatitude and ShippingLongitude values. Attached are the screenshots.

Salesforce Fact #779 | Error during emptyRecycleBin()

Image
While using the Database.emptyRecycleBin() method, if there are cascade delete relationship between records then only the top level record id needs to be specified. For example, if there are account and related contact records which are to be hard deleted, only the account record id needs to be specified. Otherwise, if both the account and contact record ids are specified, we get the error: 'Invalid record id; no recycle bin entry found'. Reference:  https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_database.htm#apex_System_Database_emptyRecycleBin Attached are the screenshots.

Salesforce Fact #778 | Related record count of selected account of screen flow datatable

Image
Suppose we want to show the related contact and opportunity count of the selected account from the screen flow datatable. With the latest update of screen flow reactivity, this can be accomplished. We can create a LWC component which would use graphql wire adapter to get the count. Attached are the screenshots.

Salesforce Fact #777 | Data uniqueness violation

Have you encountered this error: The proposed data changes would violate a uniqueness constraint. If you try to create a custom label with the same name of an existing label, this error is shown. The same error can be encountered while updating approval process. Reference:  https://help.salesforce.com/s/articleView?id=000386951&type=1

Salesforce Fact #776 | Error while deleting file association with library

Have you encountered this error:  Cannot complete this operation. You cannot remove a document from its owning library. So, whenever we associate a file to a library, a record gets created in each of ContentWorkspaceDoc and ContentDocumentLink objects. If we try to delete any of these records, it throws the error. So, the file or the ContentDocument record itself needs to be deleted to delete the associations. Reference:  https://salesforce.stackexchange.com/questions/317241/delete-a-contentdocumentlink-of-library-file

Salesforce Fact #775 | Dynamic error message using flow custom error component

Image
Another advantage of using custom error component in record-triggered flow is the use of dynamic error message. In this example, we want to ensure that if entered, the Account Number should be of exactly 10 characters. So, we can display the remaining character count in the error message when the user enters less or more digits than 10. Attached are the screenshots.

Salesforce Fact #774 | Check if a file is shared with a library

Image
How to know if a File has been shared with a Library? Once a file is added to a Library, a record is created in the ContentWorkspaceDoc object. We can query this object with the ContentDocumentId to check if a file is shared with a library. Reference:  https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_contentworkspacedoc.htm Attached are the screenshots.

Salesforce Fact #773 | Hide contact phone and email in screen flow datatable

Image
Suppose there is a scenario where we need to show the contact email and phone in screen flow datatable only if a particular custom permission is assigned to the user. Otherwise, it would be hidden to the user. We can implement the same using a bit of formula logic. Attached are the screenshots.

Salesforce Fact #772 | Reactive screen flow datatable

Image
Screen flow reactivity is available with DataTable as well. Suppose we have a scenario where we have a datatable in screen flow and the selected row needs to be auto-populated in a lookup input. We can get this using reactivity on the screen flow. Note: This will only work for single select datatable because for multiple selection, it is a collection of records in screen flow but in lookup it expects collection of ids. so, it doesn't work. Attached are the screenshots.

Salesforce Fact #771 | Query OpenID configuration

How to query the OpenID connect configuration for the org? We can use the below endpoint to query the same: https://<MyDomainName>.my.salesforce.com/. well-known/openid-configuration Reference:  https://help.salesforce.com/s/articleView?id=sf.remoteaccess_using_openid_discovery_endpoint.htm&type=5

Salesforce Fact #770 | Preselect rows in screen flow datatable

Image
In screen flow datatable, we have a Default Selection option using which we can make few rows pre-selected. In this example, we are preselecting the account rows where Rating = 'Cold'. Attached are the screenshots.

Salesforce Fact #769 | Using accountId field to store account name in screen flow datatable

Image
In screen flow datatable, we cannot show field value from the related record. However, we can use the parent record Id field to store the intended field value. For example, we want to access the related account name from the contact record. So, we can use the AccountId field to store the account name temporarily in the flow. Note: This approach will work only if the AccountId is not needed to be accessed since that would get replaced with the account name. Attached are the screenshots.

Salesforce Fact #768 | Website field showing record detail page url in screen flow datatable

Image
Suppose we have a scenario where we need to show the hyperlink in the screen flow datatable for account records which would navigate to the record detail page. We can make use of the Website field since it is of type URL and store the record detail page url in this field temporarily and show the same in the datatable. And the user can navigate to the record detail page using the url. Attached are the screenshots.