Very odd posting error (ship and invoice a sales order)

dlerouxdleroux Member Posts: 87
We have a customer using nav 4/SQL who is getting a very odd posting error under fairly specific circumstances.
The error is:
The Reservation Entry already exists

This involves posting a sales order for an inventory item with item tracking and the serial numbers have been assigned already. They did not throw the error about serial numbers being required.

Now custom code is involved(pasted below), but the custom code does not reference the reservation entry table. I thnik that my problem is occuring because I am calling the posting codeunit from C/AL code rather than the magical way base Navision calls it via property settings on the menu item. I would like to think that Navision is setting a property or otherwise initializing something that I am unaware of.

BUT, the customer does not get the error when the invoice is posted from a superuser account, only from a "peon" account. This is the thing which just blows my mind.

Can anyone provide any insight?

// mod to add qty validation before posting
   AllowToPost := TRUE;
   txtConfirmQty :='';
   KTICOde := '';

   TmpDetail.INIT; //tmpdetail is record var for Sales Line
   TmpDetail.SETFILTER("Document Type", 'Order');
   TmpDetail.SETFILTER("Document No.", Rec."No.");
   TmpDetail.SETFILTER(Type, 'Item');
   IF TmpDetail.FIND('-') THEN
     IF NOT TmpDetail.Nonstock THEN BEGIN
       ItemLedger.INIT; // record var for Item Ledger Entry
       ItemLedger.SETCURRENTKEY("Item No.");
       ItemLedger.SETRANGE("Item No.", TmpDetail."No.");
       ItemLedger.SETRANGE(ItemLedger."Location Code", TmpDetail."Location Code");

       QtyAtLoc := ItemLedger.Quantity;
       IF QtyAtLoc < TmpDetail."Qty. to Ship" THEN BEGIN
          IF STRLEN(txtConfirmQty) < 180 THEN BEGIN
             txtConfirmQty := txtConfirmQty + 'Item No. ' + FORMAT(TmpDetail."No.", 20);
             txtConfirmQty := txtConfirmQty +   ' qty to ship = ' + FORMAT(TmpDetail."Qty. to Ship",7);
             txtConfirmQty := txtConfirmQty + ' qty-on-hand = '  + FORMAT(QtyAtLoc,8) +  '\';
          END ELSE
             txtConfirmQty := txtConfirmQty + '*\';

   UNTIL TmpDetail.NEXT = 0;

   IF txtConfirmQty <> '' THEN BEGIN
      txtConfirmQty := txtConfirmQty + '\ Post Anyways?';
      AllowToPost := CONFIRM(txtConfirmQty, TRUE);
      IF AllowToPost THEN BEGIN
         GetPassCode.OPEN('Enter code to force posting #1#', KTICode);
         IF KTICode <> 'KTI' THEN
            AllowToPost := FALSE;
      END ;

IF AllowToPost THEN


  • Options
    ara3nara3n Member Posts: 9,256
    That is a realy odd bug. Try to comment out all your code and see if you still get the error. Second compare the peon permission and see what tables he doesn't have access to, and any codeunits is trying to access those tables. Normally the user should have indirect access to those tables, and the codeunit should have access to those tables.
    The error about reservation, is that a temporary table or actual table?

    Set a break point on the error and try to post with super user and see if it tries to insert in the same code and if there is any if statements and what is different in there etc.

    That's how I would attack this problem.

    Also check out SP1 for 4.0 and see if you can reproduce the error.
    Ahmed Rashed Amini
    Independent Consultant/Developer

    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    kinekine Member Posts: 12,562
    See my last answer there:


    It can be same problem...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    dlerouxdleroux Member Posts: 87
    Since i can not duplicate the problem (using their license file and user account settings) I am forced to using slower methods.

    I have tried ara3n's suggestion. They still get the error even though the trigger contains only the call to run the posting codeunit (no other processing at all). The good new is that they were able to get the error on a superuser account too, so I no longer need to cue the Twilight Zone theme when dealing with them :)

    kine, where do I enter that code? somehwere in SQL Enterprise Manager?

    Thanks to both of you.
  • Options
    kinekine Member Posts: 12,562
    Yes, you must run the code in SQL query analyzer for example... (you must run it in your Navision database on SQL server...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.