< Return to the Knowledge Base Home Page
Contents
Overview
This article outlines how to track time on Task records (Activities) using the Time Tracking (“Stopwatch”) component.
Because you can’t create Task Lookup fields, you can’t create a Task Lookup field on the Time Tracking Summary object, which means you can’t directly link to a Task in the Stopwatch component. To get around this, the Task Link object is used by the component to connect a Time Tracking Summary record(s) to a Task. By configuring the Time Tracking List component properties in a specific way, you can track time against Task records, with the component handling the creation of Task Link records as needed.
Task Links
The Task Link object is used to link a Time Tracking Summary to a Task record. Due to the inability to create a lookup field to the Task object, there is not a direct relationship between the three objects, but rather, when the components properties are configured in a specific way, the component will create a Task Link record and set it as the value for the Task Link
field on the Time Tracking Summary object. At the same time, the Task Link which was related to the Time Tracking Summary will also be set as the value for the Task Link
field on the Task object. With the Task Link set on the lookup field on both objects, they are now connected by being related to the same link.
Configure Component Properties For Use With Task Links
In order to configure the component to track time on Task records using Task Links, the properties of the component need to be configured in a specific way. In the case where you want to track time on the Task object, set the Second Lookup Field and Second Lookup Default Value properties to TTracking__Task_Link__c (TTracking__Task_Link_Object__c)
.
When the properties are configured as above, the component will determine if there is a value in the Task Link
field on the Time Tracking Summary when loading. If there is not a value in the field, the second lookup field will instead be replaced with text. On click of the Start button, the component will insert a Task Link record and update the Task Link
field on both the Time Tracking Summary and Task record. If the Task Link
field is already populated on the Time Tracking Summary, then the Task Link
lookup field will display as normal with the Task Link defaulted in.
Configure Component Properties For Use With WhatId & WhoId
An additional function of the component properties when used on the Task object is the ability to default the Second Lookup Field value based on the WhatId
and WhoId
fields on the Task. These fields are polymorphic, meaning they can contain one of many different object types. When chosen in the component properties, the value in the WhatId
or WhoId
can be defaulted into the Second Lookup Field value if compatible. The component will get the chosen value from the selected field on the Task object. If the object type of the value is the same as the chosen second lookup field, the value will be defaulted.
For example, let’s say you choose TTracking__Test_Opportunity_Look_up__c (Opportunity)
as the Second Lookup Field and WhatId
as the Second Lookup Default Value. If the WhatId
value on the Task is an Opportunity, then it will default into the Opportunity lookup field on the component, otherwise, it will not.