Gravatar for

Question by mjcarter49, Oct 14, 2016 12:37 PM

Need UniqueID for Custom Button

I'm working with someone who is build a customer button to gather the search results into a collection for files. Using ('#search").coveo("ResultList') , it was expected that the UniqueID or PrintableURI would be returned. What should be used?

Gravatar for

Comment by amoreau, Oct 14, 2016 1:09 PM


May I know if you are trying to do this in Coveo for Sitecore? If so, you might want to try using Coveo.$('#<%= Model.Id %>') for Web Forms or Coveo.$('@Model.Id') for MVC.

I'm not sure if this could fix your issue. If you could give me a bit more context (for example, which version and which release of Coveo you are using), that would be of great help to better answer your question.


Gravatar for

Comment by mjcarter49, Oct 14, 2016 1:14 PM

Hi Alex, this is Coveo for Salesforce v2.31. He is adding the button to a standard search page within SFDC.

Gravatar for

Comment by François Lachance-Guillemette, Oct 14, 2016 2:03 PM

Hi @mjcarter49 :)

I don't quite understand what you are trying to do here. $("#search").coveo("ResultList") tries to initialize the $("#search") component as a ResultList, which is most likely not what you are looking for.

Could you explain your use case so we can help you better and point you in the right direction?


Gravatar for

Comment by mjcarter49, Oct 14, 2016 2:10 PM

This is what I believe this person is trying to do. They are adding a button to the search results page labeled 'Generate PDF'. For each result returned, they are attempting to build a PDF document containing each of the results. He would like to know what command to use so that he can grab the Unique ID from the search results that are displayed.

He has already done this using's search results and is trying to do this with Coveo.

Gravatar for

Comment by François Lachance-Guillemette, Oct 14, 2016 4:07 PM

It would be easier to directly use the API to get the Unique IDs instead of trying to parse the HTML.

Here is an example that is inspired by this doc

Coveo.executeQuery().done(function(data) {
    for(var i = 0 ; i < data.results.length; i++) {
1 Reply
Gravatar for

Answer by deven, Oct 16, 2016 8:41 AM

After doing some research, I am able to get the search results using following query

$('#search').coveo('executeQuery').done(function(data) {

            for(var i = 0 ; i < data.results.length; i++) {

However it is fetching only the first page results. If I try to execute following query to fetch more results


This is throwing an error as "More than one component is bound to this element. You need to specify the component type"

Additionally, I tried to call the displayMoreResults call on the CoveoResultSet component, like below


However it updates the first page results to include those additional results. To conclude this query

  • Is there a way that we can define a hidden ResultSet Component and just update that?
  • Is there any method to get total number of search results for a possible query? I am currently using "$('.CoveoQuerySummary .coveo-highlight').last().html()" selector to get the total query results.
Gravatar for

Comment by François Lachance-Guillemette, Oct 18, 2016 12:31 PM

You could first fetch the ResultList object using the example noted in this tutorial:

var resultListInstance = $('.CoveoResultList').coveo('get');

And then use the available methods referenced in the documentation

var results = resultListInstance.getDisplayedResults();

There are other options in the documentation if this example does not exactly what you want.

Ask a question