Posts

Showing posts from July, 2023

Salesforce Fact #731 | Login as experience user permission

The permissions needed to login as a partner or customer user are: 1) Manage external users or Manage partner users 2) Edit on the Account record Reference:  https://help.salesforce.com/s/articleView?id=sf.networks_create_external_users.htm&type=5

Salesforce Fact #730 | POC on HTTP callout from screen flow

Image
Now we can do HTTP callout from flow. Currently the supported methods are GET and POST(Beta). In this example, we are doing a callout from screen flow to get the capital of the selected country. The endpoint is: https://restcountries.com/v3.1/name/{countryName}?fields=capital Reference:  https://www.apexhours.com/http-callout-into-flow-builder-without-code/ Attached are the screenshots.                                                External  Credential   Named Credential   Permission Set  Screen Flow

Salesforce Fact #729 | LWC getRecords in screen flow

Image
Suppose we have a lookup component in the screen flow which allows selecting multiple accounts. Now, we have a requirement to get the data of the selected accounts. We can get that using an LWC which makes use of getRecords wire method to fetch the required data and display in the UI. References:  https://developer.salesforce.com/docs/platform/lwc/guide/reference-wire-adapters-records.html https://dev.to/tdrnk/lwc-getrecords-wire-adapter-how-to-retrieve-records-dynamically-apd Note: The LWC UI styling can further be improved. It is just for demonstration purpose. Attached are the screenshots.

Salesforce Fact #728 | ContactId in Opportunity

The ContactId field on opportunity is a read-only field and it is not visible in the page layout. This field can be updated only using the IsPrimary flag of the Opportunity Contact Role. Reference:  https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_opportunity.htm

Salesforce Fact #727 | Quick action execution from apex

Image
We can execute quick actions from Apex code using the QuickAction class.  Reference:  https://salesforce.stackexchange.com/questions/320915/run-quick-action-from-batch Note: currently only quick actions of type 'Create a record' and 'Update a record' are supported. Attached is the screenshot.

Salesforce Fact #726 | Accessing polymorphic fields in graphQL LWC

Image
How do you access Polymorphic fields in graphQL wire adapter in LWC? Suppose we want to access the related case owner names of an account in graphQL. Since, Case Owner is a polymorphic field so we need to consider both the user and queue owner possibilities. Reference:  https://developer.salesforce.com/docs/platform/lwc/guide/reference-graphql-relationships.html Attached are the screenshots.

Salesforce Fact #725 | Validation on record delete using screen flow

Image
We know that in order to add validation during record deletion we need to go with trigger addError() method. But suppose we have a scenario where we want to put restriction on record deletion from UI if a user is not assigned a particular custom permission. We can have a screen flow in this case which can be used as a quick action. In this example, the user is only allowed to delete an account record is he/she has the custom permission 'Delete Account' assigned. Attached are the screenshots.

Salesforce Fact #724 | Update related records other the latest one

Image
Suppose we have a scenario where we need to update the related records for a parent record other than the latest child record. So, we can use for each loop to iterate over the records after retrieving them in descending order of createddate. Since a collection cannot be modified while being iterated, we need to get the child records collections in a list and then remove the first record, else it would not remove the first child record from the list. Note: The code snippet is only for demonstration purpose. Attached are the screenshots.

Salesforce Fact #723 | Related contacts in screen flow using GraphQL LWC

Image
Today let's see another use case with reactive screen components. And this time, we have the GraphQL API as well. Suppose, we have a use case where we have a lookup input on the screen flow for selecting an account record and on selecting the account, we want the related contact records(upto 10). We can create an LWC to fetch related contacts for an accountid using GraphQL API and expose the same in the screen flow. Attached are the screenshots.

Salesforce Fact #722 | validation rule message for inaccessible field

We have two options to display validation rule error message in UI: Field/Top of page. Now, if the field is not present in the layout or if the user does not have access to the field, the error position gets changed to 'Top of Page' automatically. Reference:  https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_validationrule.htm

Salesforce Fact #721 | Default end date based on start date value in screen flow

Image
Another example for reactive screen components. Suppose, we have two date input fields: start date and end date. The end date should be by default, 30 days from start date and can be edited further by the user. We can set the default value using a formula resource and within the same screen. Attached are the screenshots.

Salesforce Fact #720 | Reactive screen flow inputs with LWC

Image
With the reactive screen components feature, now we can pass value to the LWC in the same screen. Although all the input types are not supported as of now. In this example, we have a lookup input in screen and once the records are selected in flow, they are passed to LWC. For list of supported inputs, please check:  https://help.salesforce.com/s/articleView?id=sf.flow_build_reactive_set.htm&type=5 Attached are the screenshots.

Salesforce Fact #719 | DAY_ONLY() to get records within two dates

Suppose we need to fetch a list of records between two dates and also needs to skip for 2 days within the range. The filter field is of datetime type. We can make use of the DAY_ONLY() function for this. In this example, we are fetching account records created between 2023-07-01 and 2023-07-16 and skip the records created on 2023-07-06, 2023-07-07. SOQL:  SELECT Id, Name, CreatedDate  FROM Account WHERE DAY_ONLY(CREATEDDATE) >= 2023-07-01 AND DAY_ONLY(CREATEDDATE) <= 2023-07-16 AND DAY_ONLY(CREATEDDATE) NOT IN (2023-07-06, 2023-07-07)

Salesforce Fact #718 | CURRENCYRATE()

How to get the currency conversion rates in formula fields in a multi-currency org? We have a function called CURRENCYRATE() which can be used for this. It takes the CurrencyIsoCode as the input and returns the corresponding conversion rate with respect to the corporate currency. Reference:  https://help.salesforce.com/s/articleView?id=sf.customize_functions_currencyrate.htm&type=5

Salesforce Fact #717 | Day of week using reactive screen components

Image
Another use case related to reactive screen components. Suppose, we need to see the day of week for an input date value instantly in screen flow. We can use a formula resource to use WEEKDAY() function and use a text input to show the day of the week. Attached are the screenshots.