CurrFieldNo (in Event) OnAfter Validate FIELD

Steve
Member Posts: 81
Looking for best practice on this and clarification.
I'm using events to do a majority of my changes to base tables and utilized this event several times. The only time the event is triggered is when the field you set in the property is validated, but the local function sends the CurrFieldNo. Is it best practice to test for the CurrField No being the same as you specific in the function property? or not?
Using code such as:
LOCAL [EventSubscriber] OnAfterValidateAccountNo(VAR Rec : Record "Gen. Journal Line";VAR xRec : Record "Gen. Journal Line";CurrFieldNo : Integer)
IF CurrFieldNo <> 4 THEN
EXIT;
Or
IF CurrFieldNo <> FIELDN0("Account No.") THEN
EXIT;
Then do my coding....
***Basically do you need to add the code in BOLD? or skip it?
Thanks
I'm using events to do a majority of my changes to base tables and utilized this event several times. The only time the event is triggered is when the field you set in the property is validated, but the local function sends the CurrFieldNo. Is it best practice to test for the CurrField No being the same as you specific in the function property? or not?
Using code such as:
LOCAL [EventSubscriber] OnAfterValidateAccountNo(VAR Rec : Record "Gen. Journal Line";VAR xRec : Record "Gen. Journal Line";CurrFieldNo : Integer)
IF CurrFieldNo <> 4 THEN
EXIT;
Or
IF CurrFieldNo <> FIELDN0("Account No.") THEN
EXIT;
Then do my coding....
***Basically do you need to add the code in BOLD? or skip it?
Thanks
Steve
0
Best Answers
-
No, it will only run when that field is changed.
As I recall It is the value of what field that raised the event.
Say you have an event on unit price in SO line, and you change the quantity and that results in a new unit price, because of Sales Prices calculation. Then the CurrFieldNo is Quantity field number, because that's what caused the event, as the user did not touch Unit Price field.
That way you can find out and navigate around unwanted events, cause by validate on other fields.
Test it and let me know If i remember correctly.
I have used it in a single project, but can't remember.Follow me on my blog juhl.blog5 -
Here is some documentation on how CurrFieldNo behaves:
xRec and CurrFieldNo
I don't think it tells the whole truth, but might still help you to make the right decision.5
Answers
-
No, it will only run when that field is changed.
As I recall It is the value of what field that raised the event.
Say you have an event on unit price in SO line, and you change the quantity and that results in a new unit price, because of Sales Prices calculation. Then the CurrFieldNo is Quantity field number, because that's what caused the event, as the user did not touch Unit Price field.
That way you can find out and navigate around unwanted events, cause by validate on other fields.
Test it and let me know If i remember correctly.
I have used it in a single project, but can't remember.Follow me on my blog juhl.blog5 -
Here is some documentation on how CurrFieldNo behaves:
xRec and CurrFieldNo
I don't think it tells the whole truth, but might still help you to make the right decision.5
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