There’s an example on the WebAPI documentation of how to retrieve a related entity and their columns. As I was following this documentation to retrieve an owner lookup, I unexpectedly got an error and then did some digging to see why this failed.
Once you know how to retrieve the owner of a record, regardless of it being a team or a user, it will seem obvious but compared to a standard lookup it is slightly different.
Here’s the code to retrieve an owner of a record. For sake of example, I’m just retrieving the id and the name of the record but you can add your own columns in the expand section of the method.
Here you can see I’m not selecting any rows from the account but am expanding rows on the ‘owninguser’ and the ‘owningteam’ entities. This is how you retrieve an owner of a record regardless if it’s a user or a team, this is technically retrieving both values but only one will be populated and the other will be null, you can see how I handle this in the success callback of the retrieve function.
I hope this makes retrieving the owner of a record using the WebAPI nice and simple for you!