Tuesday, 26 November 2024

How to use Data Tables and filter component in Screen Flow?

 Business Requirement 

You are salesforce Admin working in Acute Care company, receives patient referral from different hospitals, Intake user need to assign each patient to some facilities that has been configured under hospital Account. And if patient is already referred one facility then It should filter.

Here is salesforce object references and Data Model 

Lead - Stores Patient Information 

Account - Hospital Account 

Facility - Facility Information 

Hospital Facility Mapping - Junction object between Account and Hospital Facility Mapping. 

Opportunity - Created under Lead stores how many facility lead has been referred, so It is junction between  Lead and Facility.




Solution without using Apex and LWC

  1. Create a Quick Action Named Assign Facility on Lead, which calls a screen flow.

     2. On click of Assign Facility button, user can select which Facility to add.



     3. Here is the whole flow. Let me explain each component


a.      a. First Get Opportunity Record Type- It is a get record element to get recordtypeId of Opportunity



b.     bGet Hospital Account Id from Lead – It is a get record element to query referring hospital Account which is look up field from Lead to Account. Since flow going to be launched from Lead record, recordId variable will have Lead Id.


CGet Hospital Mapping Records: It is a get record element to get all child records(facility configured) under particular hospital Account. Used referring hospital Account Id from previous step in query filter



d.     d. Create Facility Opportunities – Screen component containing data table where Source Collections configured all records retrieved from previous step c.



e.      e. Loop through Hospital Mappings Records



f.        f. Assign Opportunity Fields – Assignment element under loop to add all required field mapping for opportunity



g.      g. Store Opportunity to a List – Assignment element under loop to add single opportunity variable to a list.



h.      h.Get Opportunities Record For Lead – Get record element to get opportunities created under same lead.



i.        i. Decision element to check If Lead has any opportunity, If there is not any opportunity then Create record element to create all opportunities. Refer list variables used in step g





j.         j. If there are any opportunities present under lead, then run loop



k.      k. Filter element run list variables step -g, compare current item’s facility should not match listopportunities facility.



l.        lNow facilities will be filtered, there will be another list variable created, Use filtered list variable to do null check.



m.  mCreate element to created opportunities, refer filtered list.

n.      nError Screen to show any error occurred.







 






How to Enforce Customer ID Format ?

 Business Requirements: 

Each customer should have one customer Id in particular format and unique so that It can be sync other systems. Some customers may not have customer Id. If user add any customer information and enter customer Id then enforce that the customer ID should include the 2-character billing country code, a dash, and an 8-digit number (for example, US-12345678). Each customer ID must be exactly 11 characters in length with zero spaces.

Solution:

1. Create a custom field on Account which is Text Type (length 11) and unique.

2. Create formula field Billing_Country_Code__c to get country code from Account address.

Billing_Country_Code__C = TEXT(BillingCountryCode)

3. Write Validation rule 

Customer_ID_Format 
 
AND(
    NOT(ISBLANK(Customer_ID__c)),
OR((LEFT(Customer_ID__c , 2) != Billing_Country_Code__c ),
NOT(REGEX(Customer_ID__c, "^[A-Z]{2}-\\d{8}$"))
  )

    
 )

(LEFT(Customer_ID__c , 2) != Billing_Country_Code__c - Checking if user entering correct country code or not.

Error Message : Please add customer Id in proper format.'XX-NNNNNNNN' where X is the 2-character billing country code and N is an 8-digit number.


Tuesday, 19 November 2024

How to use Conditional formatting in Lighting page/Dynamic form?

 Business Use Case : You need to high light case number based on case information, type of Case. This will be helpful for service agent to take glance of Case.

If Census Type is Discharge then Red Color 

If Census Type is Admission then Green Color 

If Census Type is Continued Stay and NOMNC is Yes then Blue Color 

If Census Type is Continued Stay then Purple Color. 

Conditional Formatting

Assign custom icons and colors that can appear, disappear, and change color based on the rules you create on fields. 

 

For Example: Admission Census Type - Green



Discharge: Red 

Continued Stay and NOMNC is yes- Blue

Continued Stay and NOMNC is No - Purple 

We can add many icons not only just star, Here are list of icons.


How can you configure conditional formatting rule ?

 We can configure in highlight panel and also in lighting record page. In order to apply in highlight panel we need to use dynamic highlight panel.


  1. Go to the Record Page where you want to apply conditional formatting. For our Case , It is Case Record Page.
  2. Select Field where you want to see image and highlighted color, For our Case , It is Case Number.
  3. You will see Conditional Formatting dorpdown in right side. It pulls all conditional formatting rules that are tied to Case. Even you can see all rules in Object manager of Case. When there is no rule there will be plus icon to add new Rule.
4. Here are all rules added, each rule will have one icon and color. 


5. Under one rule you have add multiple conditions. 
6. After rule configuration done, you can select same field in Dynamic Highlight Panel and choose conditional formatting rules. 

Basically you can configure conditional formatting rule per object and apply in any field of same object.