- Starter
- Standard
- Premium
With the power of TaskRay and Salesforce, it is possible to automate and manage repeatable business processes. In this article, we will go through the steps to configure an automation that will be set up to create dynamic projects based on certain criteria. Throughout this article, we will follow a common post-sale use case that occurs after an Opportunity is marked as Closed Won, which kicks off a process to onboard the new customer. As always, this process can be modified to fit unique requirements, if needed.
For more information on stitching in general, see the following article: Stitcher.
Here is a summary of what will be covered in this article:
- Sample Use Case and Configuration Overview
- Template Configuration
- Products-to-Templates Mapping Configuration
- Flow Configuration
- Flow Testing
Sample Use Case and Configuration Overview
The sample use case that we will be following throughout this article is for a common customer onboarding scenario. To summarize, the use case will follow a process where an Opportunity with Opportunity Products added is marked as Closed Won, which triggers an automation to create a dynamic TaskRay Project based on the Opportunity Products.
In this use case, once the Opportunity is marked as Closed Won, that will kick off the post-sale process to onboard the new customer, which will be managed through the new TaskRay Project that is created. The Opportunity Products will correlate with processes/steps that will need to take place as part of the new customer's onboarding project.
This is a sample configuration that can be customized to fit unique requirements or to be incorporated in other applicable automations, if needed.
Details below.
Sample Use Case and Goal
Goal
Automatically create a dynamically-constructed project when an Opportunity is marked as Closed Won. The structure and contents of the project should depend on the Opportunity Products that are added to the Opportunity.
Use Case Details
- A new customer is purchasing some product licenses, as well as some additional technical services (e.g. implementation, training, onboarding).
- An Account record is created for the new customer.
- An Opportunity record (related to the customer's Account) is created to track the details of the sale of product licenses for the new customer.
- Related to the Opportunity, there are Opportunity Products, one for every technical service that the customer is looking to purchase (e.g. implementation, training, onboarding).
- The Opportunity Products are used to determine the structure of the new project that will be created.
- When the Opportunity record is marked as Closed Won, a TaskRay Project is automatically created to track the onboarding process for the new customer.
- The new TaskRay Project is automatically created by stitching various combinations of TaskRay Templates.
- The new project is dynamically constructed based on the Opportunity Products that the customer purchased. The Opportunity Products are linked to TaskRay Templates.
Sample Template Configuration
- Templates are used to outline all the steps, or tasks, that correlate with the processes related to the different Products. In this case, the templates are organized using task groups and there are three main task groups that correlate with the products sold:
- Implementation Package
- Onboarding Package
- Training Package
- For the purpose of setting up the automation, it is also necessary to have a separate base template. This can be an empty template project, but it is necessary to be provided as an input for the automation to work (it is used to create the "shell" for the new dynamically-built onboarding project).
Tip: Depending on your use case, the base template can contain tasks as well. The base template tasks can be used to outline the process that would occur regardless of the specific Opportunity Products that determine the dynamic portions of the new project. - For reference: Intro to Templates.
Additional Architectural Details
- Products are linked to template task groups through the Template Task Group Addressable Id field. This is a packaged field provided by TaskRay.
- Opportunity Products are set up to reference the Template Task Group Addressable Id field from the related Products. This is a custom field that is configured.
Automation Overview
- The automation is set up using Flow. The Flow is triggered when the Opportunity is marked as Closed Won.
- Then, it loops through the related Opportunity Products to identify the template task groups to be used for stitching and how they should be scheduled within the new TaskRay Project.
- After that, the Flow provides inputs for the Stitch a TaskRay Project (Flow Only) apex action.
- The output is a new TaskRay Project that is built dynamically based on the inputs provided. The new project is related to the Opportunity that triggered the process.
Template Configuration
The first step of the process is to set up templates in the TaskRay Template Hub. You can learn more about creating templates here.
Set Up Templates
For the purpose of the use case outlined in this article, there are two templates that are set up as follows:
- Template 1: Product Templates
- Contains task group templates that correlate with Products sold.
- You can think of this template as a container that stores the template task groups ("Product Templates") that will be used for stitching.
- Template 2: Base Template Project
- Required for the Stitcher.
- Can be set up with or without any tasks. If needed, it can contains a general set of tasks that will apply to any project or onboarding process, regardless of the circumstances. Otherwise, it can be left empty.
In our example, we will focus on a set of products, each of which will correlate with a template task group. Whenever any of these products will be added to an Opportunity and that Opportunity is marked as Closed Won, TaskRay will create a new project that is dynamically constructed based on the products.
To summarize, these are the Products that will be used in our sample configuration:
And this is the Products Template (organized using Task Groups):
Get Template Addressable IDs
Now that templates are set up, you will need to get their Addressable IDs. These IDs will be used to configure the Flow later in the article. Here are the steps to get the necessary Addressable IDs:
- In Template Hub, locate Template 1: Product Templates and click on the Three-Dot Actions icon to access the dropdown menu.
- Select Get IDs.
- This will open an automatically generated report displaying Addressable IDs for the template task groups. Keep this report accessible - you will need to reference it later in the configuration.
You will also need to capture the Addressable ID of Template 2: Base Template Project. For the base project, you will need the Addressable ID associated with the template TaskRay Project record. If your base template is empty, you will need to look up the Addressable ID for it through a custom report.
Products-to-Templates Mapping Configuration [Admin]
Now that TaskRay Templates are set up with the applicable template Task Groups, the next step is to relate the template Task Groups you just created to the corresponding Products in Salesforce.
There are two objects at play here. First, there is the Product object, which is used to define the specifics for the product. You can think of this as the inventory. Then, there is the Opportunity Product object, which is used to track the Products being sold on the specific Opportunity. You can think of this as the bridge between the Product and the Opportunity.
For the purpose of this automation, we will need to first map the Products to the applicable Template Task Groups. Then, we will need to reference the mapped task groups from Products on the Opportunity Products.
Map Products to Template Task Groups
Out of the box, TaskRay already provides a field on the Product object that can be used for this purpose. To summarize, you will need to update all the applicable Product records and populate the Template Task Group Addressable Id field with the corresponding template task groups.
- Using Salesforce navigation/App Launcher, navigate to Products.
- Locate a Product that is used for the purpose of this automation (e.g. Implementation Package) and click on it to open its record.
- On the Product record, click on Edit.
- Update the Template Task Group Addressable Id field with the Addressable ID of the corresponding template task group (e.g. Implementation Package task group from Template 1: Product Templates). Use the Get IDs report that you generated previously for this purpose.
- Click Save.
Repeat these steps for every additional Product that will be used for the purpose of this automation (e.g. Onboarding Package, Training Package) to map those to the applicable template task groups.
Create a New Field on Opportunity Products
Next, you will need to create a new custom field on the Opportunity Product object. The formula field will be configured to reference the template task group Addressable IDs set on the Products. This will allow the Flow to reference the IDs (necessary for the Stitcher).
- From Setup, navigate to the Object Manager and select the Opportunity Product object.
- Under Custom Fields and Relationships, click on New.
- On the New Custom Field setup page, select Formula and click Next.
- On the next screen, enter Field Label (e.g. "Task Group Template Addressable ID"), for Formula Return Type select Text, and click Next.
- On the formula builder screen, configure the formula to point to the Template Task Group Addressable Id field we updated on the Product object.
- Switch over to the Advanced Formula tab.
- Click on the Insert Field button.
- Follow this path to create the formula: Opportunity Product > Price Book Entry > Product > Template Task Group Addressable Id.
- Click on the Insert button.
- This should be your formula: PricebookEntry.Product2.TASKRAY__trTemplateTaskGroupAddressableId__c
- Click Next and continue through the remaining steps to configure the field as necessary.
Flow Configuration [Admin]
Next, you will need to build the Flow that would be responsible for automatically creating dynamic projects. The Flow will be triggered when an Opportunity is marked as Closed Won, it will loop through the related Opportunity Products to determine task groups to be used for stitching, and then create a new project.
Flow Overview
Below is a sample configuration of the Flow:
Follow the steps in the sections below to configure the Flow.
Step 1: Create New Flow
- From Setup, navigate to Process Automation | Flows.
- Click on the New Flow button.
- In the New Flow modal, select the Record-Triggered Flow option.
- Click on Create.
Step 2: Configure Start and Entry Conditions
When setting up a new record-triggered flow, it is necessary to specify the object and criteria that will trigger the automated process. In this case, we will select the Opportunity object because our automation should be triggered when the Opportunity record is updated to the Closed Won stage.
- In the Configure Start modal, click into the Object field and search for Opportunity.
- For Trigger the Flow When select A record is updated.
- In the Set Entry Conditions section, for Condition Requirements select All Conditions Are Met (AND).
- For the condition, set the following:
- Field = StageName (Stage)
- Operator = Equals
- Value = Closed Won
- For When to Run the Flow For Updated Records, select Only when a record is updated to meet the condition requirements.
- Leave the remaining options as-is and click Done.
Step 3: Add Element to Get Opportunity Products
Now that the Start element is configured, the next step is to capture Opportunity Products related to the Opportunity triggering the process.
- On the Flow canvas, click on the Plus / Add Element icon below the Start element.
- Select the Get Records element.
- In the New Get Records modal, enter the Label (e.g. "Get Opportunity Products") and API Name.
- Under Get Records of This Object, click into the Object field and select Opportunity Product.
- In the Filter Group Records section, for Condition Requirements select All Conditions Are Met (AND).
- For the first condition, set the following:
- Field = OpportunityId
- Operator = Equals
- Value = $Record > Opportunity ID (could also appear as {$Record.Id} ) (clickpath: $Record > Id).
- Add another condition by clicking on the + Add Condition button and set the following:
- Field = Task_Group_Template_Addressable_ID__c (this is the formula field that was previously created to reference template task group IDs on the Opportunity Products)
- Operator = Is Null
- Value = {!$GlobalConstant.False}
- In the Sort Group Records section, set the following:
- Sort Order = Not Sorted
- How Many Records to Store = All records
- How To Store Record Data = Choose fields and assign variables (advanced)
- This will expose some additional fields. Click into the Record Collection field and select + New Resource.
- Create a new resource with the following configurations. This will be a collection variable that will store the necessary information from the Opportunity Products.
- Resource Type = Variable
- API Name = opportunityProducts
- Data Type = Record
- Allow multiple values (collection) = check/select
- Object = Opportunity Product
- Leave the rest as-is and click Done
- Back on the Get Records configuration screen, under Select Opportunity Product Fields to Store in Variable, click into the Field field and select Task_Group_Template_Addressable_ID__c.
- Select the When no records are returned, set specified values to null checkbox.
- Click Done.
Step 4: Add Loop and Assignment Elements
Next, you will need to add a Loop and an Assignment element to go through every related Opportunity Product and capture the necessary template task groups that should be used for stitching, as well as how to schedule those task groups in the new project.
Loop Element
- On the Flow canvas, click on the Plus / Add Element icon below the Get Opportunity Products element.
- Select the Loop option.
- In the New Loop modal, enter the Label (e.g. "Iterate Opportunity Products") and API Name.
- In the Select Collection Variable section, click into the Collection Variable field and select the opportunityProducts collection variable that we created earlier.
- Under Specify Direction for Iterating Over Collection, select First item to last item.
- Click Done.
Assignment Element
- One that stores the Addressable IDs of the template task groups to be used for stitching
- One for the dates to be used to schedule each task group in the new project
- One for the schedule modes to be used to schedule each task group in the new project (e.g. Start, End, or Milestone)
Before setting up the Assignment element, we will create the necessary resources, so that it will be easy to reference them within the element. Since we're here, we will also create an extra variable, which will be used later in the Apex action in the last step of the Flow.
- On the Flow configuration screen, click on the Toolbox icon to expand the left sidebar.
- Under the Manager tab, click on New Resource and configure the first resource as follows:
- Resource Type = Variable
- API Name = templateTaskGroupIdList
- Data Type = Text
- Allow multiple values (collection) = check/select
- Once saved, create another resource as follows:
- Resource Type = Variable
- API Name = taskGroupScheduleModeList
- Data Type = Text
- Allow multiple values (collection) = check/select
- Once saved, create another resource as follows:
- Resource Type = Variable
- API Name = taskGroupTargetDateList
- Data Type = Date
- Allow multiple values (collection) = check/select
- Once saved, create another resource as follows:
- Resource Type = Constant
- API Name = baseTemplateProjectId
- Data Type = Text
- Value = enter the Addressable ID value of the Base Template (Template 2: Base Template Project) (from the Get Template Addressable ID report)
Now that the variables are created, we will go to configure the Assignment Element.
- On the Flow canvas, click on the Plus / Add Element icon below the Iterate Opportunity Products Loop element.
- Select the Assignment option.
- In the New Assignment modal, enter the Label (e.g. "Assign Task Group Lists") and API Name.
- In the Set Variable Values section, you will need to have three assignment rows. For the first assignment, set the following:
- Variable = templateTaskGroupIdList (this is one of the variables that we just created)
- Operator = Add
- Value = {!Iterate_Opportunity_Products.Task_Group_Template_Addressable_ID__c} (clickpath: Current Item from Loop Iterate_Opportunity_Products > Task_Group_Template_Addressable_ID__c)
- Add another assignment by clicking on the + Add Assignment button and set the following:
- Variable = taskGroupScheduleModeList (this is one of the variables that we just created)
- Operator = Add
- Value = Start (this will use the starting date within each task group as a reference for scheduling)
- Add another assignment by clicking on the + Add Assignment button and set the following:
- Variable = taskGroupTargetDateList (this is one of the variables that we just created)
- Operator = Add
- Value = $Record > Close Date (this will use the Opportunity's Close Date as a reference to schedule each of the task groups in the new project)
- Click Done.
Step 5: Configure the TaskRay Stitching Apex Action
As the final step, you will need to configure the TaskRay Stitching Apex Action to create the new dynamic project. The apex action will be configured to create a brand new project based on the Opportunity Products.
- On the Flow canvas, click on the Plus / Add Element icon below the entire loop (after last).
- Select the Action option.
- In the New Action modal, in the Action field, search for Stitch a TaskRay Project (Flow Only).
- Enter a Label (e.g. "Stitch a TaskRay Project") and API Name.
- Under Set Input Values, click into the New Project? field and select {!$GlobalConstant.True}.
- For New Project Date Target, select {!$Record.CloseDate} (this will reference the Opportunity Close Date to schedule the new project).
- For New Project Name, enter {!$Record.Name}: Onboarding (this will reference the Opportunity name to name the new project, as well as append "Onboarding").
- For New Project Schedule Mode, enter Start.
- For New Project Template Addressable Id, select the {!baseTemplateProjectId} constant created earlier.
- For Source Object Id, select {!$Record.Id} (clickpath: $Record > Id (Opportunity Id)) (this will link the newly created project to the Opportunity that triggers the process).
- For Task Group Addressable Id List, select the {!templateTaskGroupIdList} variable created earlier.
- For Task Group Schedule Mode List, select the {!taskGroupScheduleModeList} variable created earlier.
- For Task Group Target Date List, select the {!taskGroupTargetDateList} variable created earlier.
- Click Done.
Step 6: Save and Activate the Flow
Now that the Flow is fully configured, it is time to save and activate it.
- In the top right corner of the Flow canvas, click on the Save button.
- In the Save the Flow modal, enter the Label (e.g. "Stitch a TaskRay Project from Opportunity") and API Name.
- Click Save.
- In the top right corner of the Flow canvas, click on the Activate button.
Flow Testing
As a best practice, it is always a good idea to test custom automations to make sure that they meet requirements and follow expected behavior. Custom automations can be tested using the Debug options in Flow, using sample test records.
For the purpose of testing, you can use various Opportunity records that have Opportunity Products added to them. As you test, make sure that the Opportunity Products that are used for testing are configured to be related to template task groups accordingly.