Recent Items!

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.

Nice! We’ve had to jerry-rig solutions for recent items in the past. Cool find!

Yeah, this was a huge feature Salesforce added in Summer 13 that Skuid lets you make use of.

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)

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?

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. skuid.$(function(){ //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"); });

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.

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! 

Thanks for the update Rob.

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