I am able to return my custom objects with the following, but how can I sort them by loamvalue property (this is a number value I want to sort from high to low)
{% set yacht = crm_objects("yacht", yachtid, "name,builder,yearbuilt,loamvalue") %}
{% for yacht in yacht.results %}
....
{% endfor %}
Results can be sorted using at least one order parameter in the query. For example, crm_objects(“contact”, “firstname=Bob&order=lastname&order=createdate”) will order contacts with the first name “Bob” by last name and then by createdate. To reverse a sort, prepend - to the property name like order=-createdate.
So in your case, it should be something like this:
{% set yachts = crm_objects("yacht", "order=loamvalue", "name,builder,yearbuilt,loamvalue") %}
Can you share the output of ‘yachtid’ from your code? The second param of the crm_objects function expects a query, so you can pass multiple ID’s in that query. Should look something like this:
{% set query = 'order=loamvalue' %}
{% for id in yachtid %}
{% set query = query + "&id=" + id %}
{% endfor %}
{% set yachts = crm_objects("yacht", query, "name,builder,yearbuilt,loamvalue") %}
{% set query = 'order=loamvalue' %}
{% for id in yachtid %}
{% set query = query + "&id=" + id %}
{% endfor %}
{{query|pprint}}
{% set yachts = crm_objects("yacht", query, "name,builder,yearbuilt,loamvalue") %}
Hi @Teun
Would you be able to help here(please)?
I have a developer who is using custom objects and we are trying to sort by one of the properties which has 4 possibly options.
The property is Occupancy Status and the options are either Available, Available Soon, Viewing & Occupied.
We would like to have the results sorted based on the above. However we have used the suggested code and the result is showing alphabetical order - Available, Available Soon, Occupied & Viewing. Are you able to suggest a way to override this?
Much appreciated