Recent Items!

  • 1
  • Praise
  • Updated 5 years ago
Today I wanted to add a Recent Items list to my Skuid page. It doesn't display the standard Salesforce sidebar, so I was resigned to building it out in Visualforce and Apex.

But then I thought ... I wonder if Skuid has thought of this? I created a model, typed "rec" into the sObject Type and bingo! There's a RecentlyViewed object there to be used (which I think Salesforce only made available in Summer '13). Now I can just put a table over that model and what would have taken hours or days takes 5 minutes.

We like. A lot.
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,748 Points 5k badge 2x thumb
  • stoked

Posted 5 years ago

  • 1
Photo of John Nelson

John Nelson, Product Manager

  • 3,304 Points 3k badge 2x thumb
Nice! We've had to jerry-rig solutions for recent items in the past. Cool find!
Photo of Zach McElrath

Zach McElrath, Employee

  • 50,362 Points 50k badge 2x thumb
Yeah, this was a huge feature Salesforce added in Summer 13 that Skuid lets you make use of.
Photo of Jonathan Adlerstein

Jonathan Adlerstein

  • 528 Points 500 badge 2x thumb
Can this be incorporated into the Tab pages to show only the most recently viewed items for that user? It'd be cool if you guys would update your repository to include the modeling for this...

(I tried it on my own but was unsuccessful)
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,748 Points 5k badge 2x thumb
So I've investigated this a little more and hit a snag.

In our app, we've completely "reskinned" Salesforce with Skuid. We have Skuid detail pages for account, contact and user. I assumed that when one views records through these pages, that a new record would be added to the RecentlyViewed object each time. But this isn't so.

On further reading, when we read the detail records in our SOQL query in the model, we would need to add the "FOR VIEW" clause at the end, which would ensure that RecentlyViewed is added to. (I crudely tried adding that into the limit on my model so it read "1 FOR VIEW", which amazingly didn't fail the page, but it also didn't make any difference.)

Might Skuid support this in any way?
Photo of Zach McElrath

Zach McElrath, Employee

  • 50,272 Points 50k badge 2x thumb
You nailed it here, Glenn --- we need to add "FOR VIEW" Support to Skuid Models to allow you to influence "RecentlyViewed" without having to actually override Salesforce actions.

Your workaround with the arbitrary SOQL query is the best workaround right now.
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,748 Points 5k badge 2x thumb
So I tried a quick fix on this that seems to work.

I created an inline Javascript function to do a separate SOQL select on the record using FOR VIEW. Seems crude and inefficient, but it appears to work.

//Runs a SOQL select on the client in context using FOR VIEW so as to
//insert a reference into the RecentlyViewed object.
var theRow = skuid.model.getModel('Client').getFirstRow();
sforce.connection.sessionId = skuid.utils.mergeAsText("global", "{{$Api.Session_Id}}");
var qr = sforce.connection.query("SELECT id FROM Account where Id = '"+ theRow.Id +"' LIMIT 1 FOR VIEW");
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,268 Points 20k badge 2x thumb
In the Spring 14 release - an additional property was added to the Advanced Properties of Skuid models.  If you select "Update Salesforce "Recently Viewed" info"  on the model,  records that are retrieved with that model will be added to the "RecentlyViewed" table.  

This is probably best added to the primary model on a detail page - as you probably don't want all the records in a list view table showing up as recently viewed! 
Photo of JD Bell

JD Bell, Senior Product Engineer

  • 3,006 Points 3k badge 2x thumb
Thanks for the update Rob.

Here's a screenshot of the Advanced Model properties panel: