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 clone many projects at once in their own code. Usually you would be using this apex method when you are looking to create many projects in a single transaction. This method is very useful if you are looking to create many clones at once and may have hit governor limits using other methods.
If you would like to learn more about Project Cloning and how it works, you can view the following articles:
TaskRay Clone Projects Method
The Signature for this method is:
Map<String,Id> TASKRAY.trTaskBoardController.cloneProjectsReturnIds(Map<String,Map<String,Object>> projectInfo, Map<String,Object> cloneOptions);
Parameters
-
Map<String,Map<String,Object>> projectInfo This is simply the ID of the TaskRay Project Record you would like to clone. If you are cloning a hierarchy of projects, this is the top level project for the clone.
Note: For cloning templates, you will need to utilize the TaskRay ID Resolver to convert the template Addressable ID to a Salesforce ID. This will ensure your code always clones the active version of the template.
- Project Info Entry Shape
{ myUniqueReturnMappingId1:{ templateProjectId: (Id), newName: (String), newStartDate: (Date), newEndDate: (Date), contextRecordId: (Id), depCloneBasedOnProjectStart: (Boolean), depCloneBasedOnProjectEnd: (Boolean), depCloneBasedOnDrivingMilestone (Boolean), drivingMilestoneId: (Id), drivingMilestoneDate: (Date) }, myUniqueReturnMappingId2:{...},... }
- Usage Considerations:
- contextRecordId is the Id of any SObject. After the clone is complete the apex method will populate any lookups of the same SObject type with the contextRecordId
- Only one of depCloneBasedOnProjectStart, depCloneBasedOnProjectEnd, depCloneBasedOnDrivingMilestone should be set to true
- drivingMilestoneId and drivingMilestoneDate are only required if depCloneBasedOnDrivingMilestone is set to tru
- The myUniqueReturnMappingId1-n must be unique strings. When the method returns a Map<String,Id> this string key will be available in the returned map and it's corresponding value will be the newly created project id. This will allow you to perform other operations on the project after it has been cloned.
Note: DO NOT use a - character in these unique strings. It will cause a conflict in the internal bulk clone method.
- Project Info Entry Shape
-
Map <String,String> cloneOptions The options parameter is a map of keys to values determining what features we will use in the clone operation.
- A key of 'assignInactiveToCurrent' can have a corresponding value of 'true' or 'false', this option will assign tasks which are owned by an inactive user to the current user.
Example Usage
Apex Code
Map<String,Map<String,Object>> projectInfo = new Map<String,Map<String,Object>>(); Map<String,Object> project1Details = new Map<String,Object>(); project1Details.put('templateProjectId','a02U000000aKi33IAC'); project1Details.put('newName','Fulfill sprocket'); project1Details.put('depCloneBasedOnProjectStart', true); project1Details.put('newStartDate',Date.parse('9/1/2018')); projectInfo.put('sprocket',project1Details); Map<String,Object> project2Details = new Map<String,Object>(); project2Details.put('templateProjectId','a02U000000aKijoIAC'); project2Details.put('newName','Fulfill custom widget'); project2Details.put('depCloneBasedOnProjectStart', true); project2Details.put('newStartDate',Date.parse('9/1/2018')); projectInfo.put('custwidget',project2Details); Map<String,Object> cloneOptions = new Map<String,Object>(); cloneOptions.put('assignInactiveToCurrent', true); Map<String,Id> retInfo = TASKRAY.trTaskBoardController.cloneProjectsReturnIds(projectInfo, cloneOptions); system.debug(retInfo);
Summary
- Project Records
- Task Records
- Checklist Item Records
- Team Members / Shares
- Chatter Topics
- Checklist Items for Tasks
- Chatter