Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > SDKs >

Lost tracking fields data when updating Invoice

Started by Accountancy Manager -   in SDKs

Hi,

I am having an issue whereby updating an Invoice in Xero results in the tracking fields being wiped and blanked. I have logged out the Invoice object as it is sent to Xero, and the XML body, and as far as I can tell there is nothing there that would be causing this. The documentation suggests that tracking fields are optional and we are not including them.

I am unsure exactly if this is an SDK or API issue, but I thought I would try here first.

Any advice would be appreciated.

https://drive.google.com/file/d/1dFIYWHrKvslY4QCh5h0sDMwibKHkkvvO/view?usp=sharing

https://drive.google.com/file/d/1LWsp_ejwqS1kdt037OdVSvCA75vhWQN1/view?usp=sharing
Best Reply as chosen by Accountancy Manager (Original Poster)
Hi Stu,

Line items can be a bit tricky. If you're doing an update and don't include the LineItemId with the line items, it will actually delete the existing lineitems and add new ones.
Further, even if you do provide the lineitem IDs to persist the existing lineitems, if you don't provide the existing tracking information it will be removed by the API call.

To make sure everything remains as is with no changes, you need to provide the entire lineitem object in your payload.

There is one other option: If you are updating the invoice, but not making ANY changes to the lineitems themselves (so, for example updating just the reference) you can simply not provide ANY lineitems at all and it will keep the existing ones as is.

Hope that helps,

Steven
 

Steven Brown (Xero Staff)