question

jeffdonthemic avatar image
jeffdonthemic asked chanel Deactivated edited

Ordering Items in a Category Alphabetically?

I have a node app and can successfully associate items in a category. However, I am not able to order them alphabetically. Here's what my array of associations looks like, ordered by name (I know you don't use this key, it's just for visual support). Here's the code that calls the endpoint to create the associations.

When I run this script, the items are associated to the category correctly but in a different order each time I run the script. I can successfully order the items in the category by hand using the Clover web app so I suspect the functionality is there to order them. I just can't figure out from the docs how to do this. I assumed that ordering the association array would do the trick but no joy.

I used this code as a reference. Thanks for the help!!
REST APIInventory
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

chanel avatar image
chanel Deactivated answered chanel Deactivated edited
Edit to actually answer the question:

The order that you associate the items is reflected in the current ordering. That is, when you associate Item 2, Item 3 and then Item 1 with Category A, then the list of items will appear as [Item 2, Item 3, Item 1]. The only way to change this order is to manually hand sort them (as you've pointed out) or to completely clear the items and re-associate them in the "correct" order. Clearly not efficient, but that list is only meant to keep track of the item associations themselves, not to be directly viewed or user-friendly.
4 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jeffdonthemic avatar image jeffdonthemic commented ·

Thanks @Chanel but my question wasn't how to GET items in a given category but how to PUT them to order them.

0 Likes 0 ·
chanel avatar image chanel jeffdonthemic commented ·

Sorry about the confusion! The order that you associate the items is reflected in the current ordering. That is, when you associate Item 2, Item 3 and then Item 1 with Category A, then the list of items will appear as [Item 2, Item 3, Item 1]. The only way to change this order is to manually hand sort them (as you've pointed out) or to completely clear the items and re-associate them in the "correct" order. Clearly not efficient, but that list is only meant to keep track of the item associations themselves, not to be directly viewed or user-friendly.

0 Likes 0 ·
jeffdonthemic avatar image jeffdonthemic chanel commented ·

Thanks @Chanel. Let me see if I have the right. If I have 1600 items in 23 categories and I want to order the items alphabetically in just 5 categories, I need to remove the associations from all 1600 items and then add them back into the all of the correct categories alphabetically?

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community