This feature is available on the following TaskRay Product Editions:
- Starter
- Standard
- Premium
The following article describes how Salesforce developers can take advantage of global Apex methods to construct a new project containing a dynamic set of Task Groups or add a dynamic set of Task Groups to a existing project. This Apex method is invocable and executable via Flow and the Salesforce REST API as well.
If you would like to learn more about Project Stitching and how it works, you can view the following articles:
TaskRay Clone Projects Method
The Signature for this method is:
List<Id> TASKRAY.trStitchProjectFlow.stitchProject(List<TASKRAY.trStitchProjectFlow.Request> requests);
Parameters
-
List<TASKRAY.trStitchProjectFlow.Request> requests This input parameter is a list of classes which define how to create/update a project with a dynamic set of template task groups.
-
TASKRAY.trStitchProjectFlow.Request class definition
global class Request {
@InvocableVariable(label='New Project?' required=true)
global Boolean createNewProject;
@InvocableVariable(label='Existing Project Id (only if New Project? is false)' required=false)
global Id existingProjectId;
@InvocableVariable(
label='New Project Date Target (only if New Project? is true)'
required=false
)
global Date projectDateTarget;
@InvocableVariable(label='New Project Name (only if New Project? is true)' required=false)
global String projectName;
@InvocableVariable(
label='New Project Schedule Mode (only if New Project? is true "Start", "End", or a Milestone Id)'
required=false
)
global String projectScheduleMode;
@InvocableVariable(
label='New Project Template Addressable Id (only if New Project? is true)'
required=false
)
global string projectTemplateAddressableId;
@InvocableVariable(
label='New Project Template Salesforce Id (only if New Project? is true)'
required=false
)
global Id projectTemplateId;
@InvocableVariable(label='Source Object Id (populates lookup fields on project)' required=false)
global Id sourceRecordId;
@InvocableVariable(label='Task Group Addressable Id List' required=false)
global List<string> taskGroupAddressableIds;
@InvocableVariable(label='Task Group Salesforce Id List' required=false)
global List<Id> taskGroupIds;
@InvocableVariable(
label='Task Group Schedule Mode List ("Start", "End", or a Milestone Id)'
required=false
)
global List<String> taskGroupScheduleModes;
@InvocableVariable(label='Task Group Target Date List' required=false)
global List<Date> taskGroupTargetDates;
}
-
TASKRAY.trStitchProjectFlow.Request class definition
Return Value
- List<Id> these ids correspond to the new created or updated Project Ids for each instance of the Request class
Example Usage
Apex Code
//Opportunity to relate the new project to
Id opportunityId = '0060P00000gQF98';
//Base template project Id
Id templateProjectId = 'a020P00000hVA5OQAW';
//Template Task Group Ids for products
//Keep in mind you could also look these up from opportunity products or something similar
Id sprocketFulfillmentTaskGroupTemplateId = 'a0Y0P00000EO9Wn';
Id widgetFulfillmentTaskGroupTemplateId = 'a0Y0P00000EOwmJ';
List templateTaskGroupIds = new List();
templateTaskGroupIds.add(sprocketFulfillmentTaskGroupTemplateId);
templateTaskGroupIds.add(widgetFulfillmentTaskGroupTemplateId);
List requests = new List();
//Configure the request class
TASKRAY.trStitchProjectFlow.Request req = new TASKRAY.trStitchProjectFlow.Request();
req.createNewProject = true;
req.projectTemplateId = templateProjectId;
req.projectName = 'Acme Fulfillment Project';
req.projectScheduleMode = 'Start';
req.sourceRecordId = opportunityId;
req.projectDateTarget = Date.today();
req.taskGroupIds = new List();
req.taskGroupScheduleModes = new List();
req.taskGroupTargetDates = new List();
for(Id templateTaskGroupId : templateTaskGroupIds){
req.taskGroupIds.add(templateTaskGroupId);
req.taskGroupScheduleModes.add('Start');
req.taskGroupTargetDates.add(Date.today());
}
requests.add(req);
//Run the clone
List newlyCreatedProjectIds = TASKRAY.trStitchProjectFlow.stitchProject(requests);
//Get the newly created project id
system.debug(newlyCreatedProjectIds);
Summary
- Project Records (optionally)
- Task Records
- Checklist Item Records
- Team Members / Shares
- Chatter Topics
- Checklist Items for Tasks
- Chatter