BIG PROBLEM using events in NAV2016
marvax
Member Posts: 14
Hi,
We have decided to use events in new customizations which will reduce modifying standard objects.
But our experience has demonstrated that the use of these special events brings big problems
Indeed, events are executed randomly.
Using the debugger, we have demonstrated that NAV does not always running the events (this example is an event onafterinsert on table Sales lines).
However if we recompile the object, the event is well run .... until the next time it will not be more.
HAs someone encountered the same problem?
THanks for your repply.
We have decided to use events in new customizations which will reduce modifying standard objects.
But our experience has demonstrated that the use of these special events brings big problems
Indeed, events are executed randomly.
Using the debugger, we have demonstrated that NAV does not always running the events (this example is an event onafterinsert on table Sales lines).
However if we recompile the object, the event is well run .... until the next time it will not be more.
HAs someone encountered the same problem?
THanks for your repply.
0
Answers
-
do you mean that events are some times not running?
No, I didn't face this problem before.
can you provide more details please.0 -
Yes, i mean that events are some times not running.
an example : this fonction
[b]LOCAL [EventSubscriber] Table_36_OnAfterInsert(VAR Rec : Record "Sales Header";RunTrigger : Boolean)
IF NOT RunTrigger THEN
EXIT;
[/b]
"Created user ID" := USERID;
The result is sometimes the field Created user ID is empty and sometimes the field is good.
So we have put a breakpoint in this instruction , and debugging has showed that sometimes NAV goes in the event, and sometime don't go into. And when NAV don't execute event, we recompile codeunit with the event and so NAV execute correctly the event, some hours ....
0 -
were you creating record manually?
can you simply try with
"Created user ID" := USERID;
can you sync the db once or restart the service after changes.0 -
This is a small example of code. We put lot of code in event .
For example create recupel TAxe line. And same problem, new lines are created randomly. When the user has the problem, just recompile objet and the user hasn't more the problem. but some days or hours later the user has the problem again
No need sync database, or restart service, just recompile the codeunit that contains the event.0 -
I have faced this problem in NAV 2016 CU5. What CU are you working on?0
-
Hi ishwarsharma016,
I have tested with CU12, and same problem
0 -
you forgot the MODIFY. It's the after insert. So you manually have to modify the record.0
-
I think for OnAfterInsert etc you may need to add a modify; as it after the transactional write. if you don't want to do that look at OnBefore etc0
-
Hi _tg, Hi guidorobben
I have tested with modify, same problem.
I have debugging and nav don't pass in the event !
So any code present in the event, is executed.
0 -
No, you don't need to add the modify because the table variable is called by reference! and it updates any changes you make.
Is "IF NOT RunTrigger THEN EXIT; " condition present in your event function? I think it might be causing the issue.
I resolved my problem by checking the conditions and debugging the code, I found some code which was preventing the system to enter into the event function.
Please try compiling all objects with validation.0 -
Hi ishwarsharma016
I have same problem with the code if not runtrigger.... and without the code if not ..... because i have put a breakpoint before the if not runtrigger and debugger don't stop
I don't understand your answer :
"
I resolved my problem by checking the conditions and debugging the code, I found some code which was preventing the system to enter into the event function.
"
Which code have you found that prevent the system to enter into the event function?
Thanks a lot
0 -
@ishwarsharma016
Another thing : why nav execute event every time i recompile object.
So NAV execute event randomly, and when nav don't execute event, just recompile codeunit with event and nav execute again event.0 -
there must be something wrong with environment or setup or whatever.
I have created lot of code with events and extensions but never faced such issue.0 -
@mohana_cse06 thanks for your answer. Do you work in Cloud environnement?0
-
We've been subscribing to the OnDatabase* events in CU1. It has never failed us so far.0
-
@marvax This code I am talking about was a custom publisher and custom subscriber.0
-
@ishwarsharma016 Can you describe the problem you had and your solution a bit more. From your 2nd post above it sounds like this was more of a coding issue than an actual bug in the client. Please don't take this the wrong way - I would just like to know if this is/was actually a bug in the client - I'd feel a lot happier if it was a coding issue (we all do it
) since events are becoming so critical to development now
@marvax Have you tried restarting the NST service - does this help? BTW, If this is a reproducible issue then you should really report to Microsoft - they may be able to help identify the issue or fix it in a later release if it is a bug in the client.0 -
Subscriptions are indeed in executed in random order. There's no way to know in advance which subscriber will execute first if there's more than on subscriber on an event.Lars Westman
http://www.linkedin.com/in/larswestman0 -
it doesn't matter whether it is cloud or onpremise version. it works everywhere for everyone..0
-
@mohana_cse06 our setup is a standard setup, all parameters are standard. We just work with office 365 authentication.0
-
@Kishorm yes we have restarted NFS Service. Just remember my post : i say that i put a breakpoint in standard event (@ishwarsharma016 ) onafterinsert and nav don't stop on my breakpoint, so nav don't execute event . And when i recompile object : nav stop on my breakpoint and so execute correct code (@BlackTiger my code is correct)0
-
BlackTiger wrote: »There is no such thing as "random" in computer world. 99% of "random" is developer's fault. 1% is developer's fault too. Check your code. Then ask MS to check their code.
Well there is such a thing. If the event subscribers are triggered asynchronous, depending on the state of the CPU, certain threads can get priority over others, so yes it is possible that the order in which events are triggered can appear random.0 -
Same here... onafterdelete trigger sometime executed, sometimes not executed. Could this be caused by forgetting to restart the NAV service after importing new objects?0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions



