Flow: Add Guardians to Child's Account
Prompt
Assume that you have a org where Contacts of record type Student
physically reside with Contacts of record type Guardian
in the same Account of record type Household
. Further assume that the org has many parents that are not currently associated to their children, and vice versa. Further assume that many students' parents have not yet had Contacts records created.
Create a Flow, to be placed on the Contact record page, to help resolve the issue.
Solution
Assume:
Household_Members__c
is a rollup field on Account that counts the number of Contacts in that Account- Guardian Contacts use a formula field to reference
Household_Members__c
on the Account
- Guardian Contacts use a formula field to reference
- Accounts have a record type Household that represents the home where students and guardians reside
- Contacts have record types Student and Guardian
Build Flow
Resources
- Variable
Student_Record_Id
, Text, Available for input
- Variable
Guardian_Record_Id
, Text
- Record Choice Sets
Get_All_Solo_Guardians
- Conditions:
RecordTypeId
Equals 0124W000000fbhYQAQ ANDHousehold_Members__c
Equals 1 - Configure Each Choice: Label: Name, Data Type: Text, Choice Value: Name
- Store More Contact Field Values: Field Id ->
Guardian_Record_Id
- 2x Choice Sets
Guardian_Available_Radio_Button
- Label: “I have selected the student’s guardian from the picklist.”
- Text: Guardian_Available_Radio_Button
Guardian_Not_Available_Radio_Button
- Label: “The student’s guardian is not available in the picklist.”
- Text: Guardian_Not_Available_Radio_Button
Elements
- Get Records
- Label: “Get Current Student”
- Object: Contact
- Conditions: Id Equals
Student_Record_Id
- How to Store Records: Automatically store all fields
- Screen
- Label: “Add a Guardian to this Student’s Household”
- Display Text: “Click “Next” to begin”
- Screen
- Label: “Add a Guardian to this Student’s Household”
- Radio Buttons:
Guardian_Availability_Radio_Button
, required- Choices:
Guardian_Available_Radio_Button
Guardian_Not_Available_Radio_Button
- Choices:
- Picklist
- Label: “All Guardians in a 1-Person Household”
- Choice:
{!Get_All_Solo_Guardians}
- Set Component Visibility:
Guardian_Availability_Radio_Button
DOES NOT EQUALGuardian_Not_Available_Radio_Button
- Display Text: “Your response indicates the guardian is not already in the system. You will be prompted to create a new Contact record for the missing guardian.”
- Set Component Visibility:
Guardian_Availability_Radio_Button
EQUALSGuardian_Not_Available_Radio_Button
- Set Component Visibility:
- Decision
- Outcomes:
- Guardian Available:
Guardian_Availability_Radio_Button
EQUALSGuardian_Available_Radio_Button
- Guardian Not Available: default
- Guardian Available:
Guardian Available Branch
Resources
- Choice
- Label:
Confirmed
, Choice Value:Confirmed
Elements
- Get Records
- Object: Contact
- Conditions: Id Equals
Guardian_Record_Id
- How to Store Records: Automatically store all fields
- Screen
- Display Text: Please confirm that {!Get_Selected_Guardian.Name} is the guardian of {!Get_Current_Contact.Name} by clicking the radio button below and then clicking next.
- Picklist:
- Label: “I have confirmed guardianship.”, Required
- Choice:
{!confirmed}
- Assignment
{!Get_Selected_Guardian.AccountId}
EQUALS{!Get_Current_Contact.AccountId}
- Update Records
- How to Find Records to Update: Use the IDs and all field values from a record or record collection
- Select Record(s) to Update:
{!Get_Selected_Guardian}
- Screen
- Display Text: “{!Get_Selected_Guardian.Name} has been added to {!Get_Current_Contact.Name}’s household. The flow is completed - you can click Finish to exit. Thanks!”
- Uncheck navigation to Previous
Guardian Not Available Branch
- Variable
- Label:
NewGuardianId
, Data Type text
- Screen
- Label:
Add a Guardian Screen
- Name input component, Fields to Display:
firstName,lastName
- Create Records
- Label:
Create Guardian
- Object:
Contact
- Set Field Values:
- AccountId:
{!Get_Current_Contact.AccountId}
- FirstName:
{!Name.firstName}
- LastName:
{!Name.lastName}
- RecordTypeId:
0124W000000fbhYQAQ
- AccountId:
- Store Contact Id:
Guardian_Record_Id
- Get Records
- Object:
Contact
- Id Equals
Guardian_Record_Id
- Screen
- Display Text:
- The Contact record for guardian
{!Get_Newly_Created_Guardian.Name}
has been created and added to{!Get_Current_Contact.Name}
’s household. Please visit edit the following link to add any additional contact information to the newly-created Guardian record:https://company.lightning.force.com/lightning/r/Contact/{!Get_Newly_Created_Guardian.Id}/edit
- The Contact record for guardian
- Uncheck navigation to Previous
Deploy Flow
- Contact Record Page > Edit Page > Add “Flow” element to page from Lightning App Builder
- Check the checkbox: “Pass record ID into this variable”
This page is my solution to a real-world problem that emerged while working for Wonderful Education.