I think our database got corrupt somehow and now when we try to add a line when invoicing a PO, it will throw an error when clicking off the line saying the "VendInvoiceInfoLine" line number 'x' already exists.
I dumped a backup of the database into a test environment and deleted out all the VendInvoiceInfoTable and VendInvoiceInfoLine records, and then tried to invoice a PO again. It worked...
So my question is... do these 2 tables hold any critical information? What are the repercussions of deleting all the records for these tables on the production server? From what I can see they just hold Invoices in "Limbo" that are pending completion. I can't seem to find anything wrong with my test environment post-deletion, but just being cautious. If anyone can tell me what these tables do/ what would be effected it would be helpful. Or, if anyone knows how to narrow down my search to find the bad record(s) that would help too.
You may refer to this post (community.dynamics.com/.../corrupted-data-that-may-prevent-you-to-post-a-purchase-invoice.aspx) by Dynamics AX support. It was related to corrupted data affecting purchase invoice posting. It mentioned about deleting records in a bunch of tables including VendInvoiceInfoTable and VendInvoiceInfoLine. That should answer your 1st question.
As for narrowing down the search...I'd probably use a debugger and work out what went wrong and go from there. But if the issue was likely caused by extreme cases (e.g. power outage) then maybe not worth the time to go this route.
My blog | PBC
This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
The tables VendInvoiceInfoTable and Line are set as "Transaction" tables. So be careful for just deleting all records. These tables are used for entering vendor invoices and executing workflows ons e.g. matching variances.
As Dolee suggested. Try to find out why the error occurs by debugging or take a look at the contents of the table and check the unique indexes.
André Arnaud de Calavon | Microsoft Dynamics AX Solution architect | My blog | My company
This post is my own opinion and does not necessarily reflect the opinion or view of my company, Microsoft, both its employees, or other MVPs.
Thanks for the reply guys,
I've already seen that post Dolee, and it didn't resolve my issue. Nor did stepping through the code, as this happens to any & every PO I try to invoice (and add an extra line to), so I don't think there is anything wrong with the code. I did notice that it works for every other company, just not in one of them. As I mentioned deleting all the records out 'fixed' the issue so that I could add invoice lines, so I think it's one or more bad records in one of those tables.
I'll have to just keep investigating to try and narrow down which record(s) have gone bad.
Alright, I got it.
Not sure what happened, but one of the VendInvoiceInfoTable records had 2 associated VendInvoiceInfoLine records with the same line number. Only one showed up when viewing them in the client, and when I deleted the record through the client only one VendInvoiceInfoLine of the two was removed, leaving a bad record behind. Deleting this bad record from the live server solved the issue.
If someone has the same issue, I would write a SQL query to find all VendInvoiceInfoTable(s) and their VendInvoiceInfoLine(s) where the count of the VendInvoiceInfoLine's LineNum is greater than 1.
In other words, if a VendInvoiceInfoTable record has 2 or more associated VendInvoiceInfoLine records with the same LineNum, one is probably causing a problem.
Thanks for the help.