Gravatar for jlynch@sonusnet.com

Question by Jim Lynch, Jan 4, 2016 1:53 PM

Using an expression with data-sort-criteria

I have a VisualForce page with several tabs. For all tabs, except one, I can sort by date on the sysdate field. But for one tab, I need to sort on another date field. Is there a way to introduce an expression so that I can say something like:

If "tab == Tabx" then sort by date on field X else sort by date on tab Y

Thanks Jim

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Jan 4, 2016 2:16 PM

Correction: Meant to say:

If "tab == Tabx" then sort by date on field X else sort by date on field Y

1 Reply
Gravatar for gminero@coveo.com

Answer by gminero, Jan 4, 2016 2:45 PM

In your VisualForce Page, under Page Detail - VisualForce Markup:

Look for <span class="coveo-sort-section"> and you should be able to add a class="CoveoSort"

and following our online doc: https://developers.coveo.com/display/public/JsSearch/Sort+Component

you will have to add data-sort-criteria, and specify to which tab this would apply with the data-tab component: https://developers.coveo.com/display/public/JsSearchV1/Tab+Component

Please let us know if you have any further questions regarding the documentation or the implementation itself.

Thanks

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Jan 5, 2016 1:19 PM

Here is what I currently have:

<span class="CoveoSort"
      data-sort-criteria="date descending,date ascending"
      data-tab="All,Confluence,Cases,Work Notes,Solutions,TOI, WBASearch">Date</span>

The issue is that some of the results returned for "All" results do not have a "sysdate". For those results they have another field, "cslistdate", that contains the date. Therefore, I was looking for a way to use an expression so that if the result contained a "cslistdate" then I would sort on that otherwise I would sort on the "sysdate" (date) as it currently does.

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Jan 7, 2016 5:21 PM

Since there is only one source that does not contain the sysdate field, I was thinking that I could write a simple conversion script that would copy the source's own date field to the sysdate field. However, it seems that this is not possible. Is it true that conversion scripts cannot modify system properties ?

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Jan 7, 2016 5:37 PM

Why don't you use two CoveoSort components as suggested by @gminero ? One on @cslistdate for the "All" tab and one on date for all the other tabs.

<span class="CoveoSort"
      data-sort-criteria="date descending,date ascending"
      data-tab="Confluence,Cases,Work Notes,Solutions,TOI, WBASearch">Date</span>
<span class="CoveoSort"
      data-sort-criteria="@cslistdate descending,@cslistdate ascending"
      data-tab="All">Date</span>
Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Jan 27, 2016 2:52 PM

This is what I have:

                    <span class="CoveoSort"
                        data-sort-criteria="date descending,date ascending"
                        data-tab="All,Confluence,Cases,Work Notes,Solutions,TOI,WBASearch">Date
                    </span>

                   <span class="CoveoSort"
                        data-sort-criteria="@cslistdate descending,date ascending"
                        data-tab="CSList">Date
                    </span>

When the page is first loaded, there is one Date. If I click on CSList, then a second Date appears. The second Date allows me to sort by ascending and descending while the first Date does nothing as long as I am on the CSList tab. Conversely, the first Date only affects all tabs except CSList. What I was hoping for is that only "Date" is ever displayed.

Thoughts ?

Thanks Jim

Gravatar for mlaporte@coveo.com

Comment by Martin Laporte, Jan 29, 2016 8:51 AM

In this case you really to want to arrange to have a single field shared by all documents. If you can't modify @sysdate in a conversion field (as I think I remember is the case), then you could create a new custom date field and copy in it either the value of @sysdate or of @cslistdate, depending on the document. Then you'd need a single CoveoSort using your new custom field.

Gravatar for jlynch@sonusnet.com

Comment by Jim Lynch, Jan 29, 2016 9:31 AM

Thanks for the update. Does that mean a new custom field (for example, genericSystemDate) will need to be added to each source where each source copies either the sysdate or cslistdate to genericSystemDate ? Or could this be done in a results template ?

Ask a question