# Orderby on custom object web module

**URL:** <https://community.hubspot.com/t/orderby-on-custom-object-web-module/59452>\
**Category:** CMS Development\
**Tags:** hubdb\
**Created:** [June 21, 2022, 2:50pm UTC](https://community.hubspot.com/t/orderby-on-custom-object-web-module/59452 "2022-06-21T14:50:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [June 21, 2022, 2:50pm UTC](https://community.hubspot.com/t/orderby-on-custom-object-web-module/59452/1 "2022-06-21T14:50:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Indra](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/indra/32/98381_2.png) [@Indra](https://community.hubspot.com/u/Indra)\
**Post date:** [June 22, 2022, 7:22am UTC](https://community.hubspot.com/t/orderby-on-custom-object-web-module/59452/2 "2022-06-22T07:22:13Z")

</div>

Hi @ben-duchy,

I haved tested it out, but at the documentation for [crm\_objects()](https://developers.hubspot.com/docs/cms/data/crm-objects#display-data-from-multiple-crm-records-with-the-crm-objects-function) I see the following option:

```lia-code-sample
{% set events = crm_objects("event", "limit=3&type=virtual") %}

```

So perhaps try adding the orderBy in there like this:

```lia-code-sample
{% set events = crm_objects("event", "limit=3&type=virtual&orderBy=plot_no") %}

```

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [June 27, 2022, 3:05pm UTC](https://community.hubspot.com/t/orderby-on-custom-object-web-module/59452/3 "2022-06-27T15:05:26Z")

</div>

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) %}`

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [June 27, 2022, 4:25pm UTC](https://community.hubspot.com/t/orderby-on-custom-object-web-module/59452/4 "2022-06-27T16:25:43Z")

</div>

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) %}`

---

<div class="post-metadata">

**Author:** ![Indra](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/indra/32/98381_2.png) [@Indra](https://community.hubspot.com/u/Indra)\
**Post date:** [June 28, 2022, 7:14am UTC](https://community.hubspot.com/t/orderby-on-custom-object-web-module/59452/5 "2022-06-28T07:14:42Z")

</div>

Hi @ben-duchy,

You are correct using the [int filter](https://developers.hubspot.com/docs/cms/hubl/filters#int). 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 %}`

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [June 22, 2022, 8:14am UTC](https://community.hubspot.com/t/orderby-on-custom-object-web-module/59452/6 "2022-06-22T08:14:40Z")

</div>

@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.
