Hello, everyone.
First of all, let me state that I realize there is no built-in way of sorting the items on a sales order. Well, that's disappointing, but I'll deal with it. As such, it seems that it IS possible to sort the SO if it is scripted. To me, this looks like it would be a pretty big undertaking, so I've come here for your suggestions. The reason that we want... no, NEED it sorted is because of both our process and our customers. Our picking is done via an external system that does sort, but when the packing slip isn't sorted the same way, our packers need to search the packing slip for that item just to mark it as packed. It is very time consuming. Similarly, when our customers receive their goods, they check them in too, and they have the same difficulty that our packers do. It puts somewhat of a strain on our relationship with them.
First and foremost, I want the sorting to impact the user as little as possible. I've been playing with the following ideas in my head, and I'd like to know what you think of each. Each of these assumes that there is a custom field on the order via which the salesperson selects how the SO should be sorted.
1. Sort the order every time the salesperson saves it.
This has some obvious drawbacks. What if the salesperson edited something other than the line items on the order? Why should the whole order be sorted again for that? What if the SO is very large (some of our SO's can be over 500 lines!) This would certainly cause a slowdown during the save and we don't want to impact the user if possible.
2. Schedule the sort to occur after it has been saved
This too, has drawbacks. What if the salesperson goes back into the order and does a bunch of editing? The schedule would likely run during that time and the salesperson would get a "record has been modified" error after making all their changes. What if they look at the order one minute, then leave, then go back into it? The schedule could have run during that time and suddenly all the items are in a different order. This could be confusing for them.
3. Sort the records Before or After Submit
Using a server-side script like userEventBeforeSubmit or userEventAfterSubmit would likely be faster than doing the same thing client-side, but there would still likely be a large slowdown because of it. Again, not idea.
4. Sort it live
This one is dangerous if not done very carefully. It would involve using clientValidateLine to immediately remove the newest line and rebuild it in a sorted position on the order. However, this doesn't help if the salesperson wants to change the sort order after entering the order. Plus, it would be very confusing to enter an item, then suddenly have it jump to somewhere else on the order. Finally, it's dangerous. What if something in the script doesn't work just right? There would have to be a way to ensure that the item doesn't get remove by the sort, only to fail and not be re-added. I don't like this solution.
5. Sort it on command
This seems like the most logical method. The salesperson would enter the order, then they would select the sorting method and, before any saving or anything else is done, the order is immediately sorted then and there. Then it can be saved or edited more as needed. The only problem with this solution is, again, slowdown of the browser during sorting.
So what do you guys think? Has anyone else scripted a strategy for sorting sales orders that is both quick and reliable, while also not being confusing?