Hi,
I have a system whereby when a quote is created there is an automatic line item added which is a delivery charge applied to all quotes and orders. Each customer record has a delivery charge on their company record from where the value is pulled for this. This is fine.
I have an issue where the customer would like this to appear as the last line item in the quote. On the quote entity there is a line number which I have exposed for them so they can reorder the line items as they wish but sometimes they forget to move the delivery charge to the last position. So, I need to have a script on the insert or postinsert record of lineitems that reorders them so that the delviery charge line item is always 1 more than the highest order line item in the list. Initially I had thought of creating the delivery charge line item as item number 100 and I'd hoped that as more line items were added they would start at 1 and move higher but no, they just take max line item number + 1 so any line items after the delivery charge starts at 101.
I know this is a script but I just cannot get it right. Obviously I'll be updating all quote items and I'll need to use SaveChangesNoTLS() as a function to prevent the firing of the other tablescripts on the quote.
Any help welcomed!
Lee