From Ruchi Sharma: Setup a Topic Hierarchy
Salesforce Scheduler provides a component to display and select a work type group.
By default, this component display all the work type group records, in Spring ‘22 this component is getting the capability to filter work type group records based on specified Ids.
You can check the component documentation here.
Work Type Group Hierarchy
Imagine you are a bank manager and a user is scheduling an appointment with the bank.
While scheduling an appointment you want the user to select hierarchical work type groups to know about the appointment context.
Example – Suppose the first level work type group hierarchy consists of personal banking, wealth management, etc. Based on user selection we will display the next level hierarchy. If the user selects personal banking then the second level work type group hierarchy consists of checking saving account, loan management, etc.
You can easily display work type group hierarchy in salesforce scheduler flows with clicks, not code! 🙂
Please check below 3 level hierarchy demonstration
Let’s look at how it is done,
Configuration is the same for Outbound, Inbound, and Guest flows, illustrating for Outbound Flow.
- Create a self lookup in the Work Type Group object.
This will store the parent work type group record id.
- For this feature, we will be using the ‘Filter by work type group Ids’ input configuration of the ‘Select Work Type Groups’ component.
- Add a new Assignment element called “Set filter by work type group ids as null”, after Set Topic Stage.
And the arrows pointing to the topic screen will now point to this element.
Assignment element :
In this element, we are setting the ‘FilterByWorkTypeGroupIds’ variable as null.
OOTB flow :
- After the assignment element adds a “Get Records” element to fetch the work type group records.
Initially, we are assuming variable workTypeGroupId is null.
Work_Type_Group__c is the self lookup field.
- Loop over fetched work type group records and append the work type group Ids in the “FilterByWorkTypeGroupIds” variable.
- After the loop element adds a decision element to check FilterByWorkTypeGroupIds is not null (next-level hierarchy exist) or workTypeGroupId is null (If it’s loading for the first time).
- If the next level hierarchy exists then add an assignment element to clear the previously selected work type group and connect this element to “Topic Screen“.
Else redirect to “Set Appointment Stage”.
- Optionally to display the selected hierarchy on top of the work type group selection screen, add a ‘Get Records’ element to fetch the selected work type group record.
Redirect the topic screen to this element.
Then add an assignment element and create a work type group collection variable to add the work type group record.
- Finally, connect the above assignment element to the assignment element that we have created in step 3.
- To show the selected hierarchy, drag and drop the “DisplayWorkTypeGroupHierarchy” custom component above the “Select Work Type Groups” component in the topic screen.
And pass the work type group collection variable as input to this component that we have created in step 8. (optional)
That’s it! Activate and run the flow.
All the code is bundled at https://github.com/ruchi2994/workTypeGroupHierarchy. It contains the above component and updated flow.