I am trying to submit an sales order using eConnect and keep getting this error
The following error occurred while inserting the
transaction :System.Data.SqlClient.SqlException: Violation of PRIMARY
KEY constraint 'PKAAG20000'. Cannot insert duplicate key in object
The statement has been terminated.
Server stack trace:
ConnectionString, ConnectionStringType ConnectionType, String sXML,
SchemaValidationType ValidationType, String eConnectSchema)
How do I fix it?
This error means duplicate value with primary key for the table aag20000 (aaSubLedgerHdr). Primary key for this table is aaSubLedgerHdrID. For each new row, value in this column is incremented by 1. For adding a new record, you should use max value in table plus one.
Also, note that table aag00102 in Dynamics database stores next IDs for the Analytical Accounting tables. You will require to update the value in this table for record where aaTableID=20000 and CMPANYID= (your company ID from Table SY01500)
Thank you very much. I had kind of figured out this that before.
However, AAG00102 does not contain a table = 2000 for company ID = 10. I am using a debug company that we have here. Is there any reason why this entry would be missing (not installing something) ?
The record is present for the non-debug company. If I had to insert it manually, what would be the DEX_ROW_ID?
I meant *table = 20000 (I missed a zero)
The one possible reason for the missing record in table is AAG00102, no transaction is entered/posted from sub ledger with Analytical Accounting codes so far.You can try manually entering couple of transactions (if you can) in SOP with AA codes to confirm AA is working properly. This should create the record in this table.
You don’t need to insert any value for DEX_ROW_ID (don’t include this field in insert statement). This is an auto-incremented field. SQL will automatically generate value for it.
I was getting the same error the solution posted by Rubal "Also, note that table aag00102 in Dynamics database stores next IDs for the Analytical Accounting tables. You will require to update the value in this table for record where aaTableID=20000 and CMPANYID= (your company ID from Table SY01500)" solved my problem. Thanks a lot Rubal.
Business Applications communities