Form refresh issue after deleting current record on card

Roelof
Member Posts: 377
I have a problem refreshing a salesOrder after deleting the current record. I created some custom functionality what is validating a field. If checked it will ask to delete the record. That works fine by doing a rec.delete(true). However the form itself is not refreshing. I tried to fix that by adding some code in the OnAfterValidate trigger of this field on the form as: CurrForm.Update() (used true or false, both didn't work). But whatever I try nothing seems to work. If I then close the form I receive an error that says: 'Sales Header does not exist', with the document type and No. of the record I just deleted. Is there any trick how to overcome this problem?
Roelof de Jonghttp://www.wye.com
0
Comments
-
So you are saying you have added a checkbox to the sales header & when checked it deletes the header?
Why not hit F4? or use sendkeys on check of the box to execute F4?0 -
This is some custom code with some conditions what is triggering deleting the record.
I wish I just could use the F4 button.
But...any work around? I'm stuck.Roelof de Jonghttp://www.wye.com0 -
If you can't use the F4, why not use a button that triggers the custom code and delete the record ?Microsoft Certified IT Professional for Microsoft Dynamics NAV
Just a happy frood who knows where his towel is0 -
It's not the F4 button. And the delete functionality works just fine. But.... when the record is deleted, the form is still showing the current record (believe me I tried everything possible to refresh the form, CurrForm.update(true), (False) etc... updating the OnNext, OnFind triggers of the form, everything, but the form is not refreshing and I'm receiving an error when I close the form or go to a next record as: 'Sales Header does not exist' with the information of the record I just deleted.
Any suggestions anyone?Roelof de Jonghttp://www.wye.com0 -
check if you have any filter on the form trigger.Microsoft Certified IT Professional for Microsoft Dynamics NAV
Just a happy frood who knows where his towel is0 -
You could always add RESET to clear all filters.0
-
Roelof wrote:I have a problem refreshing a salesOrder after deleting the current record. I created some custom functionality what is validating a field. If checked it will ask to delete the record. That works fine by doing a rec.delete(true). However the form itself is not refreshing. I tried to fix that by adding some code in the OnAfterValidate trigger of this field on the form as: CurrForm.Update() (used true or false, both didn't work). But whatever I try nothing seems to work. If I then close the form I receive an error that says: 'Sales Header does not exist', with the document type and No. of the record I just deleted. Is there any trick how to overcome this problem?
I think this is a bug.
I had an almost similar issue many years ago. I did a lot of things to try to resolve it, but never could. Basically in the code I have it creates the record, does some work on the record then deletes it. Sometimes the refresh does not work, and if you close the form, then open again it gives a message that the record exists.
A temporary table would solve the technical issue, but the created record needs to in the database, so that was not an option. In the end I had to add code to prevent the users form closing the form incorrectly or from being able to accidentally cause the error. And of course a lot of training. Even then, at least twice a year they have the problem, and the only fix is to either delete the users ZUP or design and save the form to lose the stored settings.
If you ever work out the issue, please let us know, it will help me too.
By the way, this started on 3.10 (native) then 4.00(native) then 5.00sp1(SQL). Each exe upgrade made it more stable, but even in 500sp1 there are still issues.David Singleton0 -
Yes, this is weird. I'm not sure if it has something to do with filter-groups in the OnOpenForm trigger. I used 'Reset' and what not but that didn't help.
I'll keep you posted if I come up with a solution.
In the meanwhile if anyone has an idea, just let me know.Roelof de Jonghttp://www.wye.com0 -
on the part of your code where you have rec.delete(true) have you thought about changing that code to sendkeys (f4) just to see if it behaves differently?
viewtopic.php?f=5&t=257120 -
I solved the problem. Finally.
What I did so far was making a call to my delete function from one of the SalesHeader table fields. Instead I'm making the call from the same field but on the SalesOrder form (header form). In the OnAfterValidate trigger I add the following code (I have done this before BUT without using the CurrPage.SAVERECORD line. That did the trick). Here is my code:
//Start
CurrPage.SAVERECORD;
Cancel_Order;
CurrPage.UPDATE;
//End
The CurrPage.SaveRecord was needed to overcome my problem. Don't ask me why.
THe CurrPage.Update is refreshing the form. (I have used this before. It didn't work until now with this 'CurrPage.SaveRecord' line)Roelof de Jonghttp://www.wye.com0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions