Thursday 30 June 2022

Salesforce Dynamic Related List in the lightning app builder

With the Salesforce Summer'22 release, Related lists can now be customized straight from the Lightning App Builder rather than the page layout editor with Salesforce's new Dynamic Related List.

What does salesforce's Dynamic Related List mean?
Dynamic Related Lists is the newest feature in the Summer’22 release, With the use of Dynamic Related List you can customize the related list directly in Lightning App Builder. By customizing a related list you can set how many records to display, which fields and actions to appear, and set filters on the related list.

Dynamic Related List – Single Component
The following characteristics set the dynamic related list - single component apart from the static related list component.

  • Define Related List Label and type of list
  • Configure Number of Records to Display 
  • Show/hide List View Action Bar
  • Define Related List Filters
  • Configure Actions 
  • Set Component Visibility

    Let's see how to add Dynamic Related List into page.

    Add Dynamic Related Lists in Lightning Page using Lightning App Builder 
    Follow the below steps to add Dynamic Related List - Single component one a Lightning Record Page, Here we are adding Dynamic Related List on a Account record page.

    • Click on Setup.
    • Click on Object Manager, Select Account.
    • Select Lightning Record Page, Click on Account Record Page.
    • Click On Edit.
    • Drag and drop Dynamic Related List – Single on the canvas.
    • After adding Dynamic Related List – Single, Configure all the properties which is shown in the below image.

    Dynamic Related List - Single
    • Clock on Save and Activate.

    Click Here to see release notes on Dynamic Related List.

    If you have any questions you can reach out our Salesforce Consulting team here.

    Thursday 23 June 2022

    Override Lightning Input Field Label In Lightning Web Component

    SCENARIO

    While working on one of the requirements for a Health sector project for a client based out of Atlanta, GA, there was a requirement to set custom labels in the place of fields standard labels in Lightning Web Component.

    CHALLENGE

    In Lightning Web Component, By using lightning-record-edit-form with lightning-input-field tag we can not set a custom label for lightning-input-field.

    APPROACH

    By hiding the label of a lightning input field and setting a custom label for a lightning input field we can set a custom label. Let's take dive into it.

    The field label is automatically obtained from the metadata description of the field when lightning-input-field is used with lightning-record-edit-form. For example, if the field's label is First Name and you send the field's API name to the lightning-input-field component, the component will display First Name as the field label.

    Let's look with the example, For contact object fields First Name, Last name and Email need to set custom labels as Contact First Name, Contact Last Name, Contact Email. Below is a code to override field labels.

    Here we have assigned an id to the lightning-input-field component and used variant attribute with value label-hidden. while define the label-hidden, it hides the actual label of the lightning input field.

    The custom label value from the label tag will be passed using the id that we have given to the lightning-input-field component.

    OUTPUT





    CONCLUSION

    By simply hiding actual label of the lightning input field and adding a custom label tag, We can override lightning input field label.

    If you have any questions you can reach out our Salesforce Consulting team here.

    Thursday 16 June 2022

    Delete Inactive Picklist Values in Bulk (Beta)

    With the Salesforce summer’22 release, we can bulk delete unused inactive picklist values. Before the release of summer’22, custom picklists with many inactive values were difficult to maintain because we can delete inactive ones at a time. let’s take a look in brief.

    Clean Up Inactive Picklist Values (Beta)

    Managing inactive picklist values and establishing restrictions on the number of inactive values for custom picklists can help your Salesforce org run more smoothly and efficiently. You can bulk delete inactive unused values from a picklist if there are a lot of them.

    Below are the steps to avail of this feature in your org.

    Active Bulk delete inactive picklist values(Beta) option

    • Click Setup.
    • In the Quick Find box, type Picklist Settings.
    • Activate Bulk Delete Inactive Picklist Values (Beta) option.

    Bulk Delete Inactive Picklist Values
    Now, we will get the option to bulk delete inactive unused picklist values.

    Below are the rules that apply while bulk deleting picklist values.

    Rules
    • This feature is available only for custom picklist fields on an object. It’s not available for standard or multi-select picklist fields.
    • This feature is only for picklist fields that have defined values. It’s not available for picklist fields that use a global value set.
    • This feature deletes inactive, unused picklist values. If a picklist value is inactive but still referenced in a record, the value isn’t deleted.
    • After you delete unused values, if a picklist is unbound and the total number of inactive values falls below the limit, the field is set to a bound picklist.
    • While the job that deletes inactive values runs, these actions are unavailable on that picklist field: Activate, Activate Selected, Deactivate, Deactivate Selected, Delete, Delete Selected, Replace, and Replace Selected. The buttons are enabled, but an error message is returned when you click them.
    • While the job that deletes inactive values runs, changes to the picklist field via Metadata API are unavailable. You can retrieve data from the field, but you can’t: create a picklist value, update the field or its values, delete the field or its values, or deploy the field.

    Follow the below steps to delete all inactive unused values from a picklist.

    • Click Setup.
    • Click on Object Manager, and select your Object.
    • Click on Fields & Relationships, and click the picklist field. In the Picklist Values Used section, you can see how many inactive picklist values the field has.
    • From the Inactive Values section of the picklist field, click Delete Unused Values.

    Delete unused values

    After all of the picklist values have been deleted, you will receive an email indicating whether or not the deletion was successful. The email is sent to the user whose email address was used to initiate the deletion.

    Click here to see release notes of summer'22 on Clean Up Inactive Picklist Values (Beta) 

    If you have any questions you can reach out our Salesforce Consulting team here.

    Thursday 2 June 2022

    Using the Button, send the Record Id to the Flow

    Scenario :
    While working on one of the requirements for a health sector project for a client based out of MelbourneAustralia there was a requirement to avail current record id in a flow by clicking a button for further actions.

    Approach : 
    The client wants a custom button on the Contact record page to launch the flow and avail the record id in a flow.

    By passing the record id in a flow URL we can get the record id in a flow. Let's see with the example. 

    Follow the below steps to create a flow.

    Screen Flow :

    Step 1:-  Define flow properties.
    • Click Setup.
    • In the Quick Find box, type Flows.
    • Select Flows then click on the New Flow.
    • Select the Screen Flow option and click on Next and configure the flow as follows:
      • How do you want to start building: Freeform
    Step 2:- Flow variable
    Define recordId Text variable to store Record Id.
    • Under Toolbox, select Manager and click on New Resource.
    • Input the following information,
      • Resource Type - Variable
      • API Name - recordId
      • Data Type - Text
      • Allow multiple values (collection) - Uncheck 
      • Available for InputCheck
    • Click Done.
    recordId variable

    Step 3:- Create Screen Element
    We will create a screen element to display Record Id in this step.
    • Under Toolbox, select Elements. Drag and drop Screen onto the canvas.
    • Fill following Information on Screen Properties.
      • Enter Label the API Name will auto-populate.
      • under Components, select Display Text, Drag, and drop Display Text onto the screenfill the following details.
        • API Name - Show_recordId
        • Insert a resource - {!recordId}
    • Click Done.
    • Connect start element to screen element.
    Screen element

    Our Flow is complete, Save and Activate the Flow. below is a diagram of the Flow.

    Flow Diagram

    Flow diagram

    Now, Our Flow looks good. Let's create a custom button on the contact object and add a button on the contact page layout.

    Custom Button

    Follow the below steps to create a button on the contact object.

    Step 1: 
    • Go to Setup > Object Manager
    • Select a Contact Object
    Step 2:
    • Go to Buttons, Links and Actions
    • Click on New Button or Link 
    Step 3:
    Fill in the below details.
    • Label - Run Flow
    • Name - Run_Flow
    • Display Type - Detail Page Button
    • Behavior - Display in new window
    • Content Source - URL
    • Fill the below URL in the text area
    /flow/Get_RecordId_In_Flow_Example?recordId={!Contact.Id}&retURL={!Contact.Id}
    

    Click on the Save button.
    Custom button

    Add the custom button to the page layout

    Below are the steps to add the custom button to the contact page layout.
    • Go to Page Layout. Select the edit option.
    • Select Mobile and Lightning Experience Actions from the panel.
    • Drag and drop Run Flow custom button to the Mobile and Lightning Experience Actions section.
    • Click Save.

    Contact page layout
    Output


    Click here to see the Trailhead badge on Distribute the Flow with a Custom Button for more information.

    If you have any questions you can reach out our Salesforce Consulting team here.