CMS Development

ben-duchy
Top Contributor

Orderby on custom object web module

SOLVE

Does anyone know how to add an 'orderBy' function on a custom object web module?

 

Connecting to HubDB I would use something like this:

{% set sites = hubdb_table_rows(1234567, "&orderBy=plot_no") %}

 

Unfortunately this doesnt work when using the following for custom objects:

{% set sites = crm_objects("sites", "limit=100", "site, plot_no") %}

 

 Any ideas? 

0 Upvotes
1 Accepted solution
Indra
Solution
Guide | Elite Partner
Guide | Elite Partner

Orderby on custom object web module

SOLVE

Hi @ben-duchy,

 

I haved tested it out, but at the documentation for crm_objects() I see the following option:

 

{% set events = crm_objects("event", "limit=3&type=virtual") %}

 

 

 So perhaps try adding the orderBy in there like this:

 

{% set events = crm_objects("event", "limit=3&type=virtual&orderBy=plot_no") %}

 


Bureau Vet

Did my post solve your question? Help the community by marking it as a solution

View solution in original post

5 Replies 5
ben-duchy
Top Contributor

Orderby on custom object web module

SOLVE

@Indra, spot on, thank you 😀

 

I'm not sure what the &type=virtual is refering to (couldnt see reference to this in the docs) so I left it out, but adding &orderBy within the same quotation as limit=3 gave me the solution I needed. Much appreciated.

 

 

Indra
Solution
Guide | Elite Partner
Guide | Elite Partner

Orderby on custom object web module

SOLVE

Hi @ben-duchy,

 

I haved tested it out, but at the documentation for crm_objects() I see the following option:

 

{% set events = crm_objects("event", "limit=3&type=virtual") %}

 

 

 So perhaps try adding the orderBy in there like this:

 

{% set events = crm_objects("event", "limit=3&type=virtual&orderBy=plot_no") %}

 


Bureau Vet

Did my post solve your question? Help the community by marking it as a solution
ben-duchy
Top Contributor

Orderby on custom object web module

SOLVE

Hi @Indra,

 

The documantation about Custom Object web modules is very small so I apologise for another question.

 

When doing a calculation between to records within HubDB I would so something like:

{% set example = (row.price - row.discount) %}

 

Unfortunately when I try and add 2 custom object fields using the below, the result is concatenating the numbers insetad of adding them together. What am I doing wrong? It should be 20000 + 5000 = 25000 but instead it displays 200005000

{% set example = (member.salary + member.bonus) %}

  

0 Upvotes
ben-duchy
Top Contributor

Orderby on custom object web module

SOLVE

Ignore me, I've found a solution.

 

For some strange reason on only addition calculations I have to specify that it is an integer:

 

{% set example = (member.salary | int + member.bonus) %}
0 Upvotes
Indra
Guide | Elite Partner
Guide | Elite Partner

Orderby on custom object web module

SOLVE

Hi @ben-duchy,

 

You are correct using the int filter. To make sure it always work, you can do it this way. Your code will be like:

{% set example = member.salary|int + member.bonus|int %}

Bureau Vet

Did my post solve your question? Help the community by marking it as a solution