OrderBy in the CAML?

Forums Autocomplete OrderBy in the CAML?

Viewing 2 reply threads
  • Author
    Posts
    • #12543
      Sergio Giusti
      Participant

      Hi I am trying to order my results in the autocomplete script. I have tried the below but although it works fine without the <OrderBy> in it, once I add orderby it stops working and doesn’t recognise the list its looking up from exists anymore. I have tried putting orderby at the front of the And and at the End, ive also tried encapsulating in a <Query> and also a <Where> but no joy on any of them, is the current CAML filter within AutoComplete limited without the ability to Sort or have I missed something? Thanks in advance.

      
      
      spjs.ac.textField({
      	"applyTo":"EventName",
      	"helpText":"Enter the event title...",
      	"listGuid":"Events",
      	"listBaseUrl":"/test",
      	"showField":"Title",
      	"enforceUniqueValues":true,
      	"rowLimit":15,
      	"listOptionsOnFocus":false,
      	"reValidateOnLoad":false,
      	"allowAddNew":false,
      	"isLookupInSelf":true,
      	"filterCAML":"<And><Geq><FieldRef Name='AvailableTickets'></FieldRef><Value Type='Number'>1</Value></Geq><Geq><FieldRef Name='Date'></FieldRef><Value Type='DateTime'><Today/></Value></Geq></And><OrderBy><FieldRef Name='Date' /></OrderBy>",
      	"setFields":[
      		{
      			"fromFIN":"Title",
      			"toFIN":"EventName",
      			"parseFunction":"",
      			"skipIfEmpty":false
      		},
      		{
      			"fromFIN":"ID",
      			"toFIN":"EventID",
      			"parseFunction":"",
      			"skipIfEmpty":false
      		}
      
      	]					
      });		
      </script>
    • #12577
      Alexander Bautz
      Keymaster

      Hi,
      Currently the result is automatically ordered by the “showField” specified in the argument object. Specifying another OrderBy column is not supported.

      Can you give me some more information as to why you need to change the default alphabetical ordering?

      Alexander

    • #12604
      Alexander Bautz
      Keymaster

      Cut from from email:

      Hi Alex

      I’m getting to order by date, the data in showing to the user is a concatenated field which is a string, am example would be

      Manchester United v Hull 02/11/2016

      The issue i have is because it’s text, so I was trying to order by another colum in the lookup list which is a date and time field

      Thanks
      Regards
      Sergio Giusti

      I have added an option to specify the sort column. See change log here: https://spjsblog.com/dffs/dffs-change-log/

      Please let me know how it works out.

      Best regards,
      Alexander

Viewing 2 reply threads
  • You must be logged in to reply to this topic.