Salesforce REST APIs support endpoints for getting updated, deleted and recentlyviewed objects. I am interested in getting the recentlyviewed items. This endpoint returns data of the form
{
"attributes" :
{
"type" : "Account",
"url" : "/services/data/v28.0/sobjects/Account/a06U000000CelH0IAJ"
},
"Id" : "a06U000000CelH0IAJ",
"Name" : "Acme"
},
{
"attributes" :
{
"type" : "Opportunity",
"url" : "/services/data/v28.0/sobjects/Opportunity/a06U000000CelGvIAJ"
},
"Id" : "a06U000000CelGvIAJ",
"Name" : "Acme - 600 Widgets"
}
The problem is that this metadata does not contain information about the person who viewed this object. To understand the working of recentlyviewed
I had to read up on how it is implemented. It seems that it is implemented using an SObject named RecentlyViewed . The explanation of this SObject says that itRepresents records that the **current user** has recently viewed or referenced
.
The current_user
would mean that it would only return the recentlyviewed
objects of the user whose access token is being used to make the API call. So in order to get the recentlyviewed
objects of all users i would have to make this API call with the access token of each and every user in the enterprise.
Here in lies my problem. I do not have the access tokens of all users in the company. I only have the access token of the enterprise admin. How do I go about getting the recentlyviewed
items of all users? Does Salesforce offer some mechanism where the admin's access token can be used to impersonate API calls on behalf of other users? If not, is there any other way of solving this?
I am open to solutions using the SOAP API also.