Best method to Add field validation in BC SaaS

jordi79jordi79 Member Posts: 275
Hi,

There are 2 ways to add a validation trigger to an existing field in BC.

1) Subscriber codeunit that subscribes to the table OnAfterValidate Event

2) A TableExtension that Modifies the field OnAfterValidate trigger

Which is best and what is the pros and cons of each method?

All this while I have been using the Subscriber codeunit method, until recently when I realised that I could also achieve the same using a TableExtension.

Thanks for reading.

Answers

  • TallyHoTallyHo Member Posts: 416
    It is the same afaik. I move my subscribers to the pageeext onaftervalidate as soon a there is one. It provides a better insight in What is modified.
  • SivaguruSivaguru Member Posts: 3
    TallyHo wrote: »
    It is the same afaik. I move my subscribers to the pageeext onaftervalidate as soon a there is one. It provides a better insight in What is modified.

    But, adding the logic to the PageExtension would only fire the code if the field was modified from that particular page which the page extension is extending. if you want the code to fire no matter which page the field was modified from, I suggest using the Table Extension or the Codeunit Method subscribing to the Table's OnAfterValidate Event.
  • TallyHoTallyHo Member Posts: 416
    I'm sorry, I meant tableextension where i wrote paggextension
  • jordi79jordi79 Member Posts: 275
    I think the table trigger events written as subscriber was used to support older versions of NAV. E.g. before BC14. This was because before BC14, you cannot write TableExt in C/side. So to get around this, we can subscribe to table events (delete, insert, modify...) via a subscriber codeunit.
Sign In or Register to comment.