Polymorphic dynamic search with Skuid?

  • 1
  • Question
  • Updated 4 years ago
  • Answered
Not sure if this is a job for Skuid, or something to be coded up with Javascript & Apex, but here goes.

I have a Skuid page called Client View that acts as the Account detail page. It's housed in a Visualforce page that overrides the standard Salesforce Account view page. I also have pages that override Contact and User. All my Skuid pages hide Salesforce's header and sidebar (we're effectively "reskinning" Salesforce) and have a common nav bar that I've created.

The user will often be on the Client View, Contact View or User View page want to easily find and navigate to another account, contact or user. My plan is to have a search box in my nav bar where the user can start typing a string and it returns matching accounts, contacts and users as they type. It's polymorphic like Salesforce's global search, but returns records as you type like a Skuid lookup field. The user selects the name of one of the returned records and clicks to navigate to its detail page.

Wondered if you could point me to the best approach to take.

Thanks as always.
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,768 Points 5k badge 2x thumb

Posted 6 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 53,702 Points 50k badge 2x thumb
Hi Glenn,

Searching across multiple objects all at once is the ideal use case for search with SOSL, which Skuid currently doesn't use or support at all via any Skuid API methods. So I'd recommend coding this up yourself right now, using JavaScript Remoting to perform the SOSL search on the Apex side, and jQuery UI Autocomplete or something like that for the front-end UI.

Zach
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,768 Points 5k badge 2x thumb
OK, that makes sense. Good to know. Thanks.
Photo of David Ross

David Ross

  • 562 Points 500 badge 2x thumb
Glenn, we are doing the same overrides to the SF native header and have the same use case.  Did you ever figure this out?  I actually was able to pull in the SF CSS and was successful at showing the native search Div/ CSS and button on our pages, but the trick now is the Skuid pages can't access the native sf js.  I used the console to try to identify the native js, but could not pinpoint it. Is there a easier way? 
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,768 Points 5k badge 2x thumb
Hey David ... we built this out exactly as Zach described: JQueryUI autocomplete, Javascript remoting and an Apex class that runs the queries. We use it for recent items and search. Works really well.
Photo of David Ross

David Ross

  • 562 Points 500 badge 2x thumb
Ok, awesome...my thinking with that setup is you will have a search field that will autocomplete as you type and bring up a list per the SOSL, i.e...."John Doe" will pass any object related that you define in the query?  

 This could be setup in two ways.

1. The field autocompletes and you click on the result you want, which takes you direct to that record. (Easiest)

2. When you click on the result it redirects to a list view page with multiple model defined tables and then you can choose the record you want. (More involved)

Thanks for the feedback! 
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,768 Points 5k badge 2x thumb
Ours is like scenario 1. User clicks into our search box and recent items instantly appear. Then once they type two characters, the autocomplete returns records from the Apex class. Each record is a link to the relevant detail page. Like this:

Photo of Emily Davis

Emily Davis, Employee

  • 3,610 Points 3k badge 2x thumb
Your app is beautiful, Glenn! I love to see what you've done with Skuid.
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,768 Points 5k badge 2x thumb
Thanks Emily! When we decided that it had to be beautiful we were wondering just how hard that might be to do, but then along came Skuid to make it a whole lot easier. It's really been great.
Photo of Gary Bailey

Gary Bailey

  • 1,648 Points 1k badge 2x thumb
Glenn, are you available to hire to implement this polymorphic search feature for our SF implementation?

Thanks, Gary
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,768 Points 5k badge 2x thumb
Hey Gary ... sorry for the slow reply, I didn't see this earlier. I've just dropped you a note on LinkedIn.
Photo of Zach McElrath

Zach McElrath, Employee

  • 53,702 Points 50k badge 2x thumb
Official Response
FYI for those interested in using SOSL with Skuid --- as of Skuid 6.8.8, Skuid now provides a native JavaScript API that you can use for performing multi-object searches on Salesforce objects using SOSL, and then displaying them in custom UI elements. The method to call is skuid.sfdc.search()--- which is documented here
(Edited)
Photo of John De Santiago

John De Santiago

  • 736 Points 500 badge 2x thumb
I am not seeing this method. Is there something I need to enable. I double checked my version (see screenshot).

Photo of Zach McElrath

Zach McElrath, Employee

  • 53,702 Points 50k badge 2x thumb
Oops, there was a misprint in my original post about the version number --- you need to have 6.8.8+, this method is not available in 6.8.7
Photo of John De Santiago

John De Santiago

  • 736 Points 500 badge 2x thumb
Thanks. I will update our version and go from there.