Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Find a Developer >

Order of lineItems getting random upon authorization of invoice

Started by Lakshmi Barthwal Chamoli -   in Find a Developer

Once i created a invoice with line items A,B,C,D in the same order , when tried to update the status to authorized and added few line items i.e E inplace of B and provided to Xero with order of lineitems i.e A,E,C,D i can see in Xero its getting random i.e in XERO after authorization is C,E,D,A ....
Is this expected behaviour ?
What can be done to ensure order when authorizing the invoice.

Hi Lakshmi,

We don't actually expose a way to specify the sort order of line items on invoices, and as such the order they are in is not guaranteed. In saying that, they will usually be saved in the order you supply them.

Things get a little more complicated when you are editing the lineitems. In your case, for the update you have two options that should preserve your line item order:
- clear the "LineItemID" field so that new line item records are created in the order you supply them;
- supply the existing LineItemID of "B" for your new line "E" when you are posting your update.

If you are really keen to be able to arbitrarily specify the sort order of line items on invoices, head over to https://xero.uservoice.com/ and post a feature request.

Hope this helps!

Dan O'Donnell (Xero Staff)  

Thanks a lot Dan . You saved me .. Timely reply is all we need ..Thanks again .Let me try and see if i can resolve this using ur suggestion or else i will post again.
I will try to remove lineItem ids from all when updating and let xero create in the same order as suppiled as i have some new line items as well to be added along with some existing lineitems .

Lakshmi Barthwal Chamoli