The following article describes how Salesforce developers can take advantage of the TaskRay Id Resolver method in their own code.
This method is focused on retrieving the Salesforce Ids of the active project from a Principle Template for use in your own code. Using this method in a loop or multiple times in a transaction would be equivalent to SOQL queries and DML statements in a loop.
One of the great things about building on the Salesforce platform is the ability to extend other features of the platform. Following that philosophy, we have provided access to a method that will return the Salesforce Id for records based on the TaskRay Addressable Id, so other developers can use it everywhere they need to provide a Salesforce Id in other Apex methods, without rebuilding the wheel.
TaskRay Convert Addressable Ids Method
The Signature for this method is:
- list<String> addressableIds This is simply a collection of the Addressable Ids of the TaskRay Template Records you would like to get Salesforce Ids for use in other existing TaskRay Apex methods
First, if you have not already, you should create an active Template in TaskRay. We will use this as the base for our cloning. For our example, our Template has an Addressable ID of 'PT_6NKvQHfRh.PJ_Hgosds1Di’
//This is our known addressable Id value
String addressableId = 'PT_6NKvQHfRh.PJ_Hgosds1Di';
//This is our collection of Principal Version Addressable Ids for which to get Salesforce Ids
List<String>addressableIds = new List<String>(); addressableIds.add(addressableId);
//Here we will return a map of the original Addressable Id value with the corresponding Salesforce Id for the active version of the template Project to be cloned
//This allows you to retrieve Salesforce Ids for more than one Addressable Id at a time, to avoid potentially hitting governor limits for SOQL
//You can use this data however you like to reference the Salesforce Id as needed
Map<String, Id> mapOfAddressableToSalesforceIds = TASKRAY.trCustomerActions.convertAddressableIds(addressableIds);
//For this example, since we know the desired Addressable Id, we can set the project Id directly
Id baseProjectId = mapOfAddressableToSalesforceIds.get(addressableId);
//And now we can use this TaskRay Project Id in every place we would normally use a Salesforce Id
This example shows the most widely used case of retrieving a TaskRay Project, however this method will return Salesforce Ids for any TaskRay object record that has an associated addressable Id, such as TaskRay Task or TaskRay Task Group. This means you can also use this method if you’d like to use our existing methods for cloning TaskRay Tasks or stitching in TaskRay Task Groups, for instance.