2

How can I get a specific object's ‘Recent Items’ object Ids in Apex or SOQL? Please note. I am not talking about the recent Items displayed on the homepage showing object types.

I couldn't find a way in Apex or the API to get the current user's recently viewed records of a SObject.

I want to render a "Recent Items" list on a custom Visualforce page that looks exactly as shown when you click a tab.

enter image description here

1
  • 2
    Since I can't see a way to move an answer to the original question, I'm editing this one to remove the 'shouting' and deleting the original closed question. Seems like an honest mistake.
    – metadaddy
    Dec 10, 2012 at 17:53

2 Answers 2

4

Building on Daniel Ballinger's answer to 'How to get recent items', the difference is really minor:

/services/data/v26.0/recent

gives you recent items like in the sidebar. "Object-specific" are well - object specific:

/services/data/v26.0/sobjects/Account
/services/data/v26.0/sobjects/Opportunity

etc.

enter image description here

Or raw output:

  "recentItems" : [ {
    "attributes" : {
      "type" : "Opportunity",
      "url" : "/services/data/v26.0/sobjects/Opportunity/0067000000AH3M7AAL"
    },
    "Id" : "0067000000AH3M7AAL",
    "Name" : "University of AZ Portable Generators111"
  }, {
    "attributes" : {
      "type" : "Opportunity",
      "url" : "/services/data/v26.0/sobjects/Opportunity/0067000000AH3M1AAL"
    },
    "Id" : "0067000000AH3M1AAL",
    "Name" : "Grand Hotels Kitchen Generator"
  }, {
    "attributes" : {
      "type" : "Opportunity",
      "url" : "/services/data/v26.0/sobjects/Opportunity/0067000000AH3MEAA1"
    }...
1
  • Thanks for pointing me to the fact that the REST API also offers Recent Items for objects. Dec 10, 2012 at 12:37
5

There is a new object that will be available in Summer '13 called RecentlyViewed that you can use in SOQL to get a user's recently viewed records.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .