Using the currentActivity.OwnerId
reference is somewhat similar to using the __c
suffix on a custom lookup or master detail field, the data you would receive back is the Id of that record rather than the object itself, in the case of the Owner field you need to use the currentActivity.Owner.FirstName
syntax to reference fields on the owner record as you would use the __r.ExampleField
syntax.
One thing to note with the above approach however is that the record owner for many objects including Leads within salesforce can be either a queue or a user. Therefore if you are looking to get FirstName of a Queue owner you will retrieve "null" for both the first and last name fields. You could write a small check into your code to mitigate this circumstance, something along the lines of the following would work nicely:
//If the owner of the record is a User (denoted by the 005 prefix to the Id)
//then we can use the first and last name, else use the .Name field from the queue.
if(((String)currentActivity.OwnerId).substring(0,3) == '005')
{
wdCreate.Name = string.valueOf(currentActivity.Work_Date__c) +
': ' + currentActivity.Owner.FirstName +
' ' + currentActivity.Owner.LastName;
}
else
{
wdCreate.Name = string.valueOf(currentActivity.Work_Date__c) +
': ' + currentActivity.Owner.Name;
}