Delete not committing/working

Rob_HansenRob_Hansen Member Posts: 296
edited 2015-01-09 in NAV Three Tier
I'm having an issue with the RTC that has me banging my head against the wall. I have a list-type form that opens up with a filtered view (basically a subtable from the Resource Card). If I open it up and have records showing in the list, I can delete them with no problem. The list shows them disappearing. I close the page. I then go back in through the same link from the Resource Card, and the records are still there! It's like the delete never committed. Is there something special I need to do here?

And there is no temporary table or anything fancy here. It's a simple RunObject action link that opens the page filtered for records for the current resource from the resource list/card pages. In the classic client, I can delete the records with no problems...it's just in the RTC that I've hit this.

I'm wondering if this was an issue at one time that may have been corrected through a hotfix I'm missing? Let me know if any of you have seen this behaviour.

Comments

  • BeliasBelias Member Posts: 2,998
    There's a slight delay from what you see in rtc and what have been done in the database: for example, if you delete a record from a list and you immediately go to classic client, table, you'll still find the record for some seconds. Can this be your problem?
    EDIT: yes, also check if the OnDeleteRecord trigger has a FALSE return value (but i assume that this code can be included in the "fancy" things, that are not in your page, you said. :mrgreen: )
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Rob_HansenRob_Hansen Member Posts: 296
    No, that's not it. In this case the records NEVER delete. I'm finding other strange behaviours as well. Here are some examples (the first one clarifies my delete issue):

    1. Deleting
    - I delete a record from the list page in the RTC
    - The record disappears
    - If I close the page and come back in, or if I press F5 to refresh, the record shows again

    2. Inserting
    - My page is opened with a filter on Resource No. (to match the value from the card)
    - I insert a new record in the list (it populates the Resource no. correctly)
    - I move off the row and the new line disappears
    - I press F5 to refresh, then I can see the new line fine (it inserted into the DB correctly)

    I'm thinking of submitting this issue to microsoft, but wanted to see if I got any feedback here first.
  • BeliasBelias Member Posts: 2,998
    quite strange... :-k what's the build no.? of your NAV?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Rob_HansenRob_Hansen Member Posts: 296
    Dynamics NAV 6.0 SP1 (6.00.29626)
  • BeliasBelias Member Posts: 2,998
    I've a more advanced build(30212). if your page can run on a standard database you can try to post the text version of the page/table in order to let me try... :-k
    P.S.: your build no. is the very first that has been released.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Rob_HansenRob_Hansen Member Posts: 296
    I'll try updating my version to see if that does the trick. On partnersource I'm not seeing a simple download for a hotfix or anything like that...just the full SP1 release. Do you know if I need to download the full installation package again?
  • BeliasBelias Member Posts: 2,998
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Rob_HansenRob_Hansen Member Posts: 296
    No luck...the latest version (6.00.31414) still has the same issue. I think I'll submit this to microsoft.
  • kinekine Member Posts: 12,562
    Have you tried to run SQL Profiler to see, what is going on on SQL server?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Rob_HansenRob_Hansen Member Posts: 296
    I've pinned down the issue here and am working to address it. I had a brain lapse as I didn't clue that I did have some custom code in the OnInsert/OnDelete triggers in the table...because it wasn't erroring out, I figured it wasn't an issue. But, it seems the RTC behaves differently than the classic client for inserts and deletes, and I need to change my approach for what I was doing. Another year or two and maybe I'll have all the RTC idiosyncrocies (er...differences versus classic) down. Although then we'll be on to the next major release and I'm sure I'll be back onto the learning curve again...ugh.
  • MauddibMauddib Member Posts: 269
    Old thread but I am having a similar issue. And I GENERALLY know the cause so I mention it here in case it helps anyone else - or in case someone can expand upon it with an explanation.

    SQL Profiler shows me a delete statement being run, it disappears from the card (6640), but it reappears if I wait, or I refresh or restart the page.

    I am on build NAV 2009 '31510'

    Frustratingly it does not happen EVERY time either. If, for example, I delete the record, ALT TAB out, ALT TAB back out again.... then when it reappears I delete it AGAIN..... then around 4 or 5 times out of 10 it will delete successfully. The rest of the time it comes back again! So the behavior is entirely random to my eyes so far.

    The issue seems to be if I put ANY code of ANY kind in ANY place on the pages OnDeleteRecord() Function. Even if I put a MESSAGE('TEST') there somewhere. Then the problem happens. And interestingly the MESSAGE or ERROR or CONFIRM does not fire. I get no message.

    Was there any fix or explanation for this? Is it a known issue? Should I simply NOT put ANY code in this function anywhere and instead try and put it in the "Confirm Deletion" function on the underlying table??
  • BeliasBelias Member Posts: 2,998
    I'd try to explicitly put an "exit(true)" in the ondeleterecord trigger of the page.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • MauddibMauddib Member Posts: 269
    Ok I was entirely wrong above, the problem was NOT solved by removing my code from that trigger. It is still there.

    So basically the line is deleted in the page - I see a DELETE FROM command being run in the profiler - but around 8 times out of 10 the line reappears.

    I honestly can not see yet how this is possible. Any ideas appreciated.
  • okioki Member Posts: 46
    Hi,
    this 'feature' can -in my opinion- only have to do with user actions on the page - the system standard does always the same. I'd had a similar phenomen. If I remembered right it will delete the record correctly if your cursor resides in a non primary key field of the record when you invoke the delete.
    If your cursor is standing in a primary key field, the record is deleted also but if you leave the primary key field, the record is inserted again especially if you have set a filter.
    I hope that this hint can help you.

    Have you investigated the text export of the page for unusual coding, filtering, timer settings or something else?

    Olli
  • MauddibMauddib Member Posts: 269
    I now suspect I may have found a quite intricate bug in Navision :)

    *** In the last line of OnDelete() of Table 39 I have a simple function call like this:

    UpdateDuplicateOnDelete(Rec)

    *** The function on Table 39 UpdateDuplicateOnDelete simply calls a codeunit

    mycodeunit.UpdateDuplicateOnDelete(PurchLine)

    *** The codeunit function has VERY simple code using a LOCAL variable to the function. Basically like this:

    PurchaseLine2.RESET;
    PurchaseLine2.CHANGECOMPANY('myothercompany');
    IF PurchaseLine2.GET(PurchLine."Document Type", PurchLine."Document No.", PurchLine."Line No.")) THEN
    PurchaseLine2.DELETE(FALSE);

    *** It works in classic but not RTC. In classic I see in the profiler the SQL coming into the server for the DELETE(FALSE) and then the DELETE on the original table.

    *** In RTC however I can see the code for the DELETE(FALSE) coming in and executing. But another "DELETE FROM" statement simply never arrives!!! It is like the .exe of Navision simply "forgets" to send the SQL to navision to delete the original record. BUT the PurchaseLine2.DELETE does work.

    *** So now when I try AGAIN to delete the original record - it works !!!! Because the DELETE(FALSE) above never runs so the .exe "Remembers" to send the SQL Statement it should be sending.
  • MauddibMauddib Member Posts: 269
    Ok my last post on this I hope. I am 100% certain this is a 2009 SP1 bug now. I have tried to reproduce it in 2013 and it is not there.

    The reason for my conclusion is I changed my code in the function from GET to SETRANGE with FINDFIRST. The problem STILL existed.

    However I then changed it to SETRANGE with DELETEALL and the problem disappeared.

    My guess is that somewhere in the EXE for the middle tier, there is a check that a delete has been run already. If it has it does not send the SQL to delete the record again.

    The bug must be it ONLY does this security check using KEY and TABLE. Not COMPANY. So the middle tier Thinks my record was already deleted using an SQL statement, so it does not try to delete it again and will not re-generate new SQL statements for this.

    DELETEALL however sends completely differnt SQL statements, so the check does not "fail" me here. The middle tier does not make the mistake of thinking it generated this SQL statement already.

    In 2013 they must have repaired this and not use Key, Table AND company to perform this check. Therefore both SQL statements are generated correctly by the Middle Tier!!! My guess is they repaired it without even realizing. :)

    So I will just use DELETEALL for now, which should repair my direct issue, and look forward to my upgrade to 2015 which we will be doing soon once all departments are fully switched from classic client to RTC in here :)

    Anyone who wishes to report the bug directly to MS can do so, but I think SP1 goes out of maintenance with them soon anyway, so they likely will not care :)
Sign In or Register to comment.