- 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 of setting up a Flow that will automatically create TaskRay Projects from templates whenever Opportunities are marked as Closed Won. Throughout the article, we will follow a common post-sale use case that occurs when an Opportunity is 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 example, if you need to change the object or the criteria that is used to trigger the automation to create a new project from a template, that can be adjusted accordingly. Similarly, if you need to make further updates to the new project once it is created, that can also be incorporated in the automation.
Here is a summary of what will be covered in this article:
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 is marked as Closed Won, which triggers an automation to create a new TaskRay Project.
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 TaskRay Project is created by way of cloning a template that was previously configured to outline all the steps (tasks) that must be executed to onboard the new customer.
This is a sample configuration that can be customized to fit unique requirements or to be incorporated in other applicable automations, if needed.
For more information on cloning templates in general, see the following article: Clone Templates.
Details below.
Sample Use Case and Goal
Goal
Automatically create a project when an Opportunity is marked as Closed Won. The project should be created by way of cloning a TaskRay Template.
Use Case Details
- A new customer is purchasing some product licenses.
- 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.
- 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 cloning a TaskRay Template.
Sample Template Configuration
- Templates are used to outline all the steps, or tasks, that should be executed as part of the onboarding process. A template is set up for the purpose of the automation.
- For reference: Intro to Templates.
Automation Overview
- The automation is set up using Flow. The Flow is triggered when the Opportunity is marked as Closed Won.
- The Flow captures the necessary data that is then used as inputs on the Clone a TaskRay Project apex action to create the new TaskRay Project.
- The output is a new TaskRay Project that is related to the Opportunity that triggered the process.
Template Configuration
The first step of the process is to set up the template in the TaskRay Template Hub. You can learn more about creating templates here.
Set Up the Template
For the purpose of this automation, you will need to create a template that will be used to create the new projects. For the purpose of this article, a template is set up to outline the process to onboard new customers.
In the sample template, the process is defined using the following components:
- Task Groups define the different phases of the onboarding
- Tasks are used to track specific action items
- Checklists are used to outline specific details and to-do's related to certain tasks
- Dependencies are set up to prescribe the order in which Tasks should be executed
At a high level, here is what our template looks like:
Get Template Addressable ID
Now that the template is set up, you will need to get its Addressable ID. This ID will be used to configure the Flow later in the article. Here are the steps to get the Addressable ID:
- In Template Hub, locate the template 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. for the purpose of this automation, you will need the Addressable ID of the TaskRay Project. Keep this report accessible - you will need to reference it later in the configuration.
Flow Configuration [Admin]
Now that the template is set up, the next step is to build the actual automation to create new projects. For this purpose, we will be using Flow.
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 Assignment Element to Set Up Collection Variables
The following step is in place to set up an additional mapping between the newly created project and the Account of the new customer. In our use case, the Account will be referenced through the Opportunity (Account field), and it will be mapped to the Account field on the project.
For this purpose, the Clone a TaskRay Project apex action provides a set of inputs: Map Source Field and To Project Field. These inputs must be populated using collection variables that store the API names of the mapped fields. The collection variables are set up using an Assignment Element.
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 = mapSourceField
- Data Type = Text
- Allow multiple values (collection) = check/select
- Once saved, create another resource as follows:
- Resource Type = Variable
- API Name = toProjectField
- Data Type = Text
- Allow multiple values (collection) = check/select
- Once saved, create another resource as follows:
- Resource Type = Constant
- API Name = templateProjectAddressableId
- Data Type = Text
- Value = enter the Addressable ID value of the Template (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 Start element.
- Select the Assignment element.
- In the New Assignment modal, enter the Label (e.g. "Assign Map Source & To Project Values") and API Name.
- In the Set Variable Values section, you will need to have two assignment rows. For the first assignment, set the following:
- Variable = mapSourceField (this is one of the variables that we just created)
- Operator = Add
- Value = AccountID (this is the API name of the field from the source object that is being referenced for mapping; in this case, this is the API name of the Account field on the Opportunity object)
- Add another assignment by clicking on the + Add Assignment button and set the following:
- Variable = toProjectField (this is one of the variables that we just created)
- Operator = Add
- Value = TASKRAY__trAccount__c (this is the API name of the field on the TaskRay Project that is being updated with mapping; in this case, this is the API name of the Account field on the TaskRay Project object)
- Click Done.
Step 4: Configure the Clone a TaskRay Project Apex Action
As the final step, you will need to configure the Clone a TaskRay Project Apex Action to create the new project. The apex action will be configured to create a brand new project by cloning a template.
- On the Flow canvas, click on the Plus / Add Element icon below the Assignment element.
- Select the Action option.
- In the New Assignment modal, in the Action field, search for Clone a TaskRay Project.
- Enter a Label (e.g. "Clone a TaskRay Project") and API Name.
- Under Set Input Values, click into the Source Object Id field and select {!$Record.Id} (clickpath: $Record > Id (Opportunity Id)) (this will link the newly created project to the Opportunity that triggers the process).
- For Map Source Field (API Name), select the {!mapSourceField} variable created earlier.
- For To Project Field (API Name), select the {!toProjectField} variable created earlier.
- For Project Name, enter {!$Record.Name}: Onboarding (this will reference the Opportunity name to name the new project, as well as append "Onboarding").
- For Starting Date of First Task (pick one), select {!$Record.CloseDate} (clickpath: $Record > Close Date) (this will use the Opportunity's Close Date as a reference when scheduling the new project).
Note: In this sample configuration, the new project is going to be scheduled using the first task that is going to be scheduled on the date that is specified as the Opportunity's Close Date. The rest of the tasks from the template will be scheduled relative to the first task's date as it was defined on the template. With that said, it is also possible to use one of the other scheduling parameters provided with the apex action instead (e.g. Ending Date of Last Task or Milestone). Those options will work the same way, except that they will use different tasks for reference when scheduling. With the Ending Date of Last Task option, the project will be scheduled backwards relative to how the last task is scheduled. Similarly, the Milestone option will use the specified milestone task from the template to schedule all the other tasks around itself according to the relative schedule defined on the template. Please note that in order for the Milestone option to work, the template project must be set up to include a milestone. - For Template Project Addressable Id, select the {!templateProjectAddressableId} constant created earlier.
- Click Done.
Step 5: 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. "Clone 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 an Opportunity record and update it to Closed Won.