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
Steve
0
Answers
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.
xRec and CurrFieldNo
I don't think it tells the whole truth, but might still help you to make the right decision.