This article will walk you through how to view records you are assigned to from child objects in a list view on the parent record. Currently the best way to view this information would be through a report, however this report would need to be customized for each user. Reports can also require multiple clicks and searches to get to the right one. Your users are going straight to the object, wouldn’t it be nice to give them the option to select a list view to dynamically display records they are assigned to? Giving users a list view directly from the parent object will allow users to quickly navigate and view their records while reducing the need for custom reports.
The below scenario is based on work we’ve done with a mid-sized commercial bank leveraging Salesforce and nCino for their loan origination. This solution can be used by anyone needing the ability to assign users to records in Salesforce, with the benefits of providing users an easily accessible view of records assigned to them so they can quickly monitor deals and work to close them faster.
The above screenshot displays all Loans (custom object) that have been assigned to me through a custom object called Loan Team Members. Loan Team Members works similar to Account Team and Opportunity team where you assign users via a related list. Through this related list we can assign multiple people to the team and assign multiple users to the same role if needed. If we were to simply create lookup(user) fields for each role we would only be able to assign one user to each.
Create the custom object Loan Team Members as a child object (Master-Detail) to the Loan custom object. On this child object “Loan Team Members” we are going to want a lookup (User), and a picklist for Role with options for Underwriter, Servicer, and Closer.
After you have created a child object to assign team members we are going to want to create fields on your parent record. The first will be a custom text area (255) field named “Loan Team Member ID.” This field will be used to store all user IDs on the Loan of all users assigned as team members on the “Loan Team Member” child Object. Later we will create a custom formula field that looks at the text field to see if it contains the current running users ID, as well as a formula to display the current user’s role if they are a part of the Team Members.
How will we populate this text field with all of the user IDs? The answer: Flow.
Create a Flow using Visual workflow to loop through all child record user ID fields and append them to the “Team Member UserIDs” text area field
- Open up a new flow to be taken to the Flow Designer Canvas.
- First we are going to create a Data Type Text variable: LoanID that will store the Parent Loan Record ID from the Loan Team Member record that triggered the flow. This variable will be passed in through Process Builder, which we will be discussed later.
- Drag and drop a Record Update onto the canvas. This will be used to clear out our Team Member UserIDs field, in case a group member has been removed from the group and we no longer want their ID to appear in this text box
- For the next step we will create a sObject Collection variable: CollLoanTeamMembers to collect all Loan Team Members that are related to the Loan
- Next drag and drop a Fast Lookup. On this lookup we will look up all Loan Team Members that have the Loan ID that was passed into the flow, we will then store these in the sObject collection variable named CollLoanTeamMembers. Below we will select which fields to store. In our example Member__c is the lookup(user) field where we select the user assigned as the team member. We will also store the value from the Role picklist.
- Create a sObject Variable: LoanTeamMembers
- Now drag and drop a loop, which will loop through all the records we previously stored in the sObject Collection Variable (CollLoanTeamMembers ) and store the values from Member__c and Role__c in the Loop Variable (LoanTeamMembers) we created.
- Create another Data Type Text Variable: UserIdList. This variable will be used to store an appended string of text with all the UserID’s and Roles from the Loop variable (LoanTeamMembers).
- Drag and drop an Assignment onto the canvas. This Assignment action will assign the variable UserIdList with the UserID from the first record in the loop, followed by a one digit number that corresponds the role they were assigned as. Once this assignment has occurred it will call the next record in the loop and append their UserID and role #. This will continue until all records have been iterated through. See below for information on RoleTranslate.
- Make sure there is an arrow going to and from the loop and assignment actions.
- The final step of the flow will be another record update that will update the loan text field we created, LoanTeamMemberID__c, with UserIdList. Drag a record update onto the canvas.
Create a formula within your flow named “RoleTranslate” with data type Number. This Role Translate is going to look at the Role that was assigned to a loan team member and translate that value into a 1-9 number. The purpose of this translation is to save space since we are limited to 255 characters in our text field on the Loan.
Use Process Builder to Launch Flow
Once the flow has been created we will need a way to launch the flow, for this we are going to use Process Builder. One thing to be aware of is that there is a limitation with this approach which is when a record is deleted the flow will not be launched and will not update the “Loan Team Member UserIDs” field, this field will not be updated until another team member record is created. A trigger could be built to solve for this limitation.
Overview of flow:
Create Process Builder to Launch Flow
- Process builder should be built off of the Loan Team Member object, and start when a Loan Team Member record is created
- Next select, No Criteria – just execute the actions!
- Action: select Flows
- Select the flow we just created
- Under Set Flow Variables we are going to assign the LoanTeamMembers__c.Loan__c.Id to the LoanID flow variable.
- We are passing in the LoanID from this Loan Team Member records because in the flow above we will be searching all Loan Team Member records that are related to this loan.
Create Dynamic Formula Field to determine if currently logged in user is a Loan Team Member
As mentioned above we will create two formula fields, one will display “1” if the current running user’s ID is in the Loan Team Member ID field, another will Display the role of that users. This second formula field is optional but will display the role they are assigned to for each loan in the list view.
- Current User Assigned formula on the Loan object. This formula is going to look at if the current running user’s UserID is in the LoanTeamMemberID field and will display 1 if true.
- Current User’s role formula, labeled Role, is going to look at the number to the right of the running users 18 digit ID and translate that number into their given role.
Create the List View
The last step. We will want to create a list view that displays all Loans that have “1” in the Current User Assigned formula fields.
Now test it out by assigning yourself as a team member. Check to make sure that your Salesforce UserID gets appended to the text area field, that the User Assigned Formula value is “1”, and check that the role field has your role. Go to the list view and see if your Loan appears. Now try signing in as another user and navigate back to the Loan; User Assigned Formula Value should be “0”. Our newly created list view should only display Loans that you were assigned as a “Loan Team Member”.
Questions on creating dynamic list views? Leave a comment below!