This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Get items order by a date property

Vardhan - Tuesday, April 15, 2014 9:02 AM:

Hi,

I am using following query to get items, it gets all the items if I don't use 'order by'.

BLOCKED SCRIPT

var Items_ = inn.newItem("Formulas","get");
     Items_.setAttribute("where","[Formulas].state = 'Approved' order by [Formulas].approved_date desc ");
     var results = Items.apply();

This is not getting the items. How to use order by in the above query?

Thank you.



Brian - Sunday, May 11, 2014 9:54 PM:

Hi Vardh,

OrderBy is a separate attribute that you set on the item.

var Items_ = inn.newItem("Formulas","get");
     Items_.setAttribute("where","[Formulas].state = 'Approved'");
     items_.setAttribute("orderBy", "[Formulas].approved_date desc ");

     var results = Items.apply();

should do what you want.

Hope this helps,

Brian.



Vardhan - Monday, May 12, 2014 5:46 AM:

Thank you so much Brian.