I’m looking for a way to create a dynamic ranked list of objects in a Workshop app. The goal would be to rank companies from 1 - n (1 being the “best”) and then allow our internal team to reference and adjust this list as needed. Each rank would only be occupied by one company at a time and moving a company up or down in ranking would automatically adjust the other relevant ranks. This doesn’t appear to be possible in Workshop today through any workarounds.
Having this functionality within Workshop would give our team clarity on where each company stands in relation to all others at any given time, help with resource prioritization, and allow ad-hoc adjustments to rank based on factors beyond any one given object property.
1 Like
Hi Tyler,
Have you already tried implementing a rank-property and a simple typescript function to solve this?
If you’re moving ranks incrementally (slow for large gaps), you could create up and down functions, that simply check the higher or lower rank and switches the values around on your selected object and the object above or below it. This function would take the rank of the selected object as the index and work from there.
If you want to set a rank in a more discrete manner - e.g. move a company from rank 44 to rank 2, you’d use these two values as bounds, run an Objects.search() on your Object Type to get objects from rank 2 to (but not including) 44, which is our active object/company.
Your function should then increase the value of the rank-property of each of these companies by 1 (2->3, 3->4, etc.), effectively lowering their rank on the list, and then set the rank of your target object to 2 (or whatever your input value is).
It’s a pretty common problem to encounter, and the only important thing to keep in mind is the sequence and the boundaries (e.g. 1 is the minimum rank value, and you exclude the target object/company from the reranking and just set the value at the end instead).
Let me know if you need more help with this.
Thank you very much for your response and suggestion. I’ll give that a go.
One catch here is if you have a very large amount of companies in your ObjectSet.
In that case, you’d want to make sure to use await/async to update the objects in parallel - again, use clever filtering to slice your ObjectSet, and then +1 to every rank below the target rank (if target is 2, then filter for rank > 2) as well as the target rank (if target is 2, then 2 gets +1).
If this is still too slow, you can add in an automation upon updating, where your function will just update the selected Company object + the object that is at the target rank, and then your automation function can process all other objects after this action has taken place.