Sorting on add-on doesn't update call

Options
This is an add-on to a single record.
Changing the sorting from any kind of field doesn't update the actual sorting of the addon's array. It takes the default database order.
(tried with single or list addon, same)

Thanks guys![CleanShot 2022-05-14 at 20.20.00.png]

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    Hey Vince,

    Your screenshot shows your addon is using the pricing_id field and also sorting on that same field. Since that is the primary key, any type of sort wouldn't change anything because there is only one possible value for this specific example.

    If you have another example, please share it. 
  • Vince
    Vince Member
    Options
    Hey Sean, thanks for your response!

    So, if we're doing addon, from a list of records, Let's say list of hotels. 
    Then for 1 specific hotel, I have a list of rooms.
    I want to pull the rooms, so I use on the hotel's API call the Add-on Room to extract room data. But, I want to extract that data by also sorting it by Room price (so I don't have to order by price on front-end).

    This is exactly what I did here, but the sorting doesn't work because indeed it takes the pre-defined order from the list. So why would there be a sorting option on add-ons? if it's not possible to order then?

    The only way I see possible to order is either to update the actual database to the order I want or to do a seperate api call just for rooms, making the add-on obsolete if I want to do any sorting on top of it when it is a list of objects.

    Or, am I missing something?
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    What you are describing is exactly what addons do, so there must be a disconnect somewhere.

    So a list of hotels with an addon of a list of rooms sorted by price per hotel?

    If I'm understanding this correctly, then the issue you are having is that your addon in your screenshot is a single addon (return type single) instead of a return type list with a sort on room price.

    Starting from scratch, this would be accomplished with the following:
    1. Query All Records Hotels
    2. click addon
    3. create new addon of type Room - list of items - sort by price 


    We also have office hours tomorrow. If you are still stuck, we can work through it then.