Find your content:

Search form

You are here

Emulate a custom object's “Recent Items” in a Visualforce page

 
Share

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


Attribution to: Robert Sösemann

Possible Suggestion/Solution #1

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.


Attribution to: Daniel Hoechst

Possible Suggestion/Solution #2

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"
    }...

Attribution to: eyescream
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/5221

My Block Status

My Block Content