Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Violation of PRIMARY KEY constraint PK##

(0) ShareShare
ReportReport
Posted on by 28,021 Super User 2024 Season 1

The other day a user came to see me with a very strange error message. In fact the message is not that strange would it be associated with a regular table or transaction... I already dealt with PK violations, but this time it was affecting a temp table in the system (dbo.##0342219).

It all starts with the Item Maintenance window, where the user wanted to search for a specific set of Items starting with the string 'SOFT'. Using the lookup glass in the Item Number field, it opens the Items search box, and then using the find icon, opens the 'Smart-list' filter dialog box. There entering the information to search for Item Numbers that begins with 'SOFT', after clicking on OK, the system returns an error message :

Since it happens not in all GP companies, I can assume that it is depending maybe on some corrupted IV00101 entries... and I traced with the SDT and created a DexSQL.log file to analyse the operation. It is a very common SQL query that is calling up the IV00101 and IV00115 with a parse on ITEMNMBR LIKE 'SOFT%'...
I did a test with a different company where the search dialog box does not use the 'Smart-List' options, but rather a basic 'Find' option :

And this time the search returned all the values correctly with no errors. Curious about the query behind this search, I traced it as well with the SDT and figured out that the SQL query was even simpler, because it was looking only for the IV00101 table (and did not care about the IV00115).

Also, the test made in other companies with the 'SmartList' like search option, did not generate any PK errors, but the data set is also slightly smaller or different.

I know that the search options are set by user and by company, but could not remember where to change it, to carry on other tests. Does anybody remember where to switch this ?

Does anybody else had such strange temp table PK error and how could it be fixed ?

Thanks in advance for your hints

*This post is locked for comments

  • Beat Bucher  GP Geek  GPUG All Star Profile Picture
    Beat Bucher GP Gee... 28,021 Super User 2024 Season 1 on at
    RE: Violation of PRIMARY KEY constraint PK##

    Hi Babu,

    I doubt that the empty UoM may cause this... but it doesn't cost much to fill it out.. The only suggestion I could provide is to run a SQL Dex log tracing or a SQL profiler trace from the server side while the lookup is executed.

  • RE: Violation of PRIMARY KEY constraint PK##

    Hi Beat,

    I went inventory smartlist and i am able to see all the line items for this item and 3 records doesnt have UOM not sure whether thats the cause for this issue.

  • Suggested answer
    Beat Bucher  GP Geek  GPUG All Star Profile Picture
    Beat Bucher GP Gee... 28,021 Super User 2024 Season 1 on at
    RE: Violation of PRIMARY KEY constraint PK##

    Have you tried to switch the Lookup type from SmartList to default Dynamics GP (see previous answer in this thread from Tim Foster) ? He confirmed that apparently there is a bug in the SQL query hidden behind the SmartList search function for this window...

  • RE: Violation of PRIMARY KEY constraint PK##

    Hi Beat,

    Sorry for not mentioning GP version.  We are in GP 2013 R2 release 12.00.1745

    Let me know what can I do to stop this error.

  • Beat Bucher  GP Geek  GPUG All Star Profile Picture
    Beat Bucher GP Gee... 28,021 Super User 2024 Season 1 on at
    RE: Violation of PRIMARY KEY constraint PK##

    Hi Babu,

    I would guess that this is the same bug as the lookup form for the Item Inquiry is the same in the Purchasing module as for the Inventory module.

    I just tested this in GP 2015R2 and the issues seems to have been fixed... I also went into my current GP 2010R2 production system and the problem is not happening anymore (and we haven't removed any inventory items AFAIK). My current release is 11.00.2351, so I guess the bug has been fixed somewhere during the latest service pack update.

    Which version of GP is this happening ?

  • RE: Violation of PRIMARY KEY constraint PK##

    Hi Beat,

    I am getting exact same error.  I went to  Purchase order processing item enquiry after entering the item number and selected to include Open purchase Orders & Historical Purchase orders and press redisplay and getting exact error.  Can you please help me.  I ran checklink against inventory with no luck.

  • Suggested answer
    Beat Bucher  GP Geek  GPUG All Star Profile Picture
    Beat Bucher GP Gee... 28,021 Super User 2024 Season 1 on at
    RE: Violation of PRIMARY KEY constraint PK##

    Hi Chris,

    To my knowledge this bug has never been fixed... we're running on the latest SP4 for GP 2010 (11.0.2320) and the problem is still there... My suggestion is to switch the 'search' mode from SmartList back to GP, this way you get around the problem, though your options are more limited to search across your item list. I've not checked if the issue is still present in GP 2013, but will do so as soon as I have a chance to fire up my test VM. Sorry for not being of more help.

  • Chris_L Profile Picture
    Chris_L 225 on at
    RE: Violation of PRIMARY KEY constraint PK##

    Hi Beat,

    Have you any answer when this will be resolved?  I have this issue with one of my clients on SP2 and cannot see this in any of the future service pack or hotfix fix lists.

    thanks

    Chris

  • Beat Bucher  GP Geek  GPUG All Star Profile Picture
    Beat Bucher GP Gee... 28,021 Super User 2024 Season 1 on at
    Re: Violation of PRIMARY KEY constraint PK##

    Update about this post :  

    Microsoft opened a bug report about this problem and recognized it as such. It will hopefully be fixed by an upcoming SP or application hotfix.

    Thanks to all for your help.

  • Tim Foster Profile Picture
    Tim Foster 8,515 on at
    Re: Violation of PRIMARY KEY constraint PK##

    To switch which lookup screen, you would go into Alternate/Modified Forms and Reports security.  Pick an ID:, choose SmartList as the Product, Choose Windows as the Type.  Goto the Inventory category, choose Items.  Change from SmartList to Dynamics GP.

    Done!

    Tim

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,253 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans