Code of onvalidate trigger of Post Code

amitaguptaamitagupta Member Posts: 43
Dear All,

Can anybody please explain why Validation Code is written in OnValidate() trigger of Post Code field of any master table? ValidateTableRelation & TestTableRelation properties is set to "NO" for the same...

Thanks,

Amita

Comments

  • MbadMbad Member Posts: 344
    You need the code because you have some special functionality on post codes/city. If you type post code and a city exists it auto inserts city. If you find more than one city for the post code you can choose which city you want inserted. This is to ease typing and cant be done by a mere tablerelation. The no in testtablerelation is done because so you dont need to have all post codes in the world in your database.
  • amitaguptaamitagupta Member Posts: 43
    Thanks for the reply...

    My question is...at what point of time does is get executed? I put a breakpoint on the code and selected post code from (say) Vendor Card. The code never executed...!
  • nunomaianunomaia Member Posts: 1,153
    The code is in table and not in form.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • amitaguptaamitagupta Member Posts: 43
    I know that the code is at table level ... but whats the use of it?
  • MbadMbad Member Posts: 344
    If the post code doesnt exists in your post code table the code exits. Do you have the post code in the table? If i was you i would read the code on the post code table(think there are 3 functions), or have a developer explain it to me.
  • nunomaianunomaia Member Posts: 1,153
    If are with trouble applying breakpoint, activate debug but stopping in every trigger, and watch code flow.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • amitaguptaamitagupta Member Posts: 43
    Mbad wrote:
    Do you have the post code in the table? If i was you i would read the code on the post code table

    The field I am talking about is on master tables like Customer/ Vendor.
    nunomaia wrote:
    If are with trouble applying breakpoint, activate debug but stopping in every trigger, and watch code flow

    I have tried this also. The code does not get executed only...
  • MbadMbad Member Posts: 344
    amitagupta wrote:
    Mbad wrote:
    Do you have the post code in the table? If i was you i would read the code on the post code table

    The field I am talking about is on master tables like Customer/ Vendor.

    The data im talking about is table 225. Does the code you enter exist there?
  • amitaguptaamitagupta Member Posts: 43
    The code I am talking about is table 18:


    Post Code - OnValidate()
    PostCode.ValidatePostCode(City,"Post Code");
    

    What is the use of it???
  • nunomaianunomaia Member Posts: 1,153
    When you insert a post code, insert the city if there is a mach in Post Code Table
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • DenSterDenSter Member Posts: 8,307
    OnValidate only fires when the field is actually validated. Just selecting it will not do this. Put your cursor in the field, turn on the debugger, hit F2 and tab away. This should start the debugger (make sure 'breakpoint on triggers' is on).
Sign In or Register to comment.