Flow to 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
  • 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

  1. Variable
    • Student_Record_Id, Text, Available for input
  2. Variable
    • Guardian_Record_Id, Text
  3. Record Choice Sets
    • Get_All_Solo_Guardians
    • Conditions: RecordTypeId Equals 0124W000000fbhYQAQ AND Household_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
  4. 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

  1. Get Records
    • Label: “Get Current Student”
    • Object: Contact
    • Conditions: Id Equals Student_Record_Id
    • How to Store Records: Automatically store all fields
  2. Screen
    • Label: “Add a Guardian to this Student’s Household”
    • Display Text: “Click “Next” to begin”
  3. 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
    • Picklist
      • Label: “All Guardians in a 1-Person Household”
      • Choice: {!Get_All_Solo_Guardians}
      • Set Component Visibility: Guardian_Availability_Radio_Button DOES NOT EQUAL Guardian_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 EQUALS Guardian_Not_Available_Radio_Button
  4. Decision
    • Outcomes:
      • Guardian Available: Guardian_Availability_Radio_Button EQUALS Guardian_Available_Radio_Button
      • Guardian Not Available: default

Guardian Available Branch

Resources

  1. Choice
    • Label: Confirmed, Choice Value: Confirmed

Elements

  1. Get Records
    • Object: Contact
    • Conditions: Id Equals Guardian_Record_Id
    • How to Store Records: Automatically store all fields
  2. 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}
  3. Assignment
    • {!Get_Selected_Guardian.AccountId} EQUALS {!Get_Current_Contact.AccountId}
  4. 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}
  5. 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

  1. Variable
    • Label: NewGuardianId, Data Type text
  2. Screen
    • Label: Add a Guardian Screen
    • Name input component, Fields to Display: firstName,lastName
  3. Create Records
    • Label: Create Guardian
    • Object: Contact
    • Set Field Values:
      • AccountId: {!Get_Current_Contact.AccountId}
      • FirstName: {!Name.firstName}
      • LastName: {!Name.lastName}
      • RecordTypeId: 0124W000000fbhYQAQ
    • Store Contact Id: Guardian_Record_Id
  4. Get Records
    • Object: Contact
    • Id Equals Guardian_Record_Id
  5. 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
    • Uncheck navigation to Previous

Deploy Flow

  1. Contact Record Page > Edit Page > Add “Flow” element to page from Lightning App Builder
    • Check the checkbox: “Pass record ID into this variable”