Created New Field in Sales Header Table and Sales Order Form

kwajahathydrokwajahathydro Member Posts: 88
Hi,

We are using Nav 2009 SP 1 and we have two companies in our database. Company A & Company B, I have created a new field under Sales Header Table and Sales Order Form, I have inserted that new field but this new field also shown in the sales order form when I open Company A, I dont want this new field to be shown in Company A, how do I write a peice of code to hide it from Company A, Pls give me some steps as under code of sales header table or sales order form, which is the place or section that I need write a small line code to hide it from Company A.

Regards
KH

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    In OnOpenForm trigger, try
    CurrForm."<Your Field>".VISIBLE := COMPANYNAME = 'Company B';
    
  • kinekine Member Posts: 12,562
    Of course, instead using hardcoded name of the company, add some new option e.g. into Company Info table and make the decision based on this. Or add some option "Show field xxx" into Sales Setup and make the condition use this. Hardcoded constants in code are bad solution...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kwajahathydrokwajahathydro Member Posts: 88
    Hi Mohana,

    When I use your code on the sales order form under the option specified by you, I put the code and then when try to save it gives error as i have defined an unknown variable, so how do i get it correct.

    Regards
    KH
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Can you show the code and where did you write?
  • kwajahathydrokwajahathydro Member Posts: 88
    Hi Mohana,

    see the code how i have written

    I go to Object Designer/Form/42, Design, Press F9, and look at the trigger mentioned by you

    Form - OnOpenForm()

    CurrForm."Change Requested Del Date".VISIBLE := COMPANYNAME = 'Interior Affairs Group Pte Ltd';

    Is this above line written by me is correct or not, but when I compile the object, it gives me error an unknown variable

    Regards
    KH
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Is your field name correct..please check once...
    where is the pointer shows after pressing ok on Error?
  • kwajahathydrokwajahathydro Member Posts: 88
    Hi Mohana,

    sorry! The field name was not right, so after reading your reply, I did checked the field and realized that it has a dot (symbol) in between so I did exactly the same and then complied the form, no error! see the code that i have written

    CurrForm."Change Requsted Del. Date".VISIBLE := COMPANYNAME = 'Interior Affairs Group Pte Ltd';

    Perfect! Many thanks for your kind help.

    Regards
    KH
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Please conside Kine's suggestion also..

    Hard coding is bad solution #-o
  • kwajahathydrokwajahathydro Member Posts: 88
    Hi Mohana,

    I am a functional consultant who has no clue of coding. Before I ask for help and get help on this forum, I put it to my local system and check it throughly and only after that I shall apply the same to the live server. So considering other options is not within my scope, I can give the requirement to the vendor but he will simply charge me half a man day to do this, so its better for me to get some advise and do it for my customer. With coding or without coding, I am ok as long as it works for me. Thanks for your advise and at same time also on the code help

    Regards
    KH
  • MBergerMBerger Member Posts: 413
    Hi Mohana,
    ...so its better for me...
    ...With coding or without coding, I am ok as long as it works for me...
    KH
    But....is it better for your client ? It works, true...FOR NOW ! Next time they add another company, the new field will show up there too, and the code has to be changed again. Working code is NOT the same as good code.
Sign In or Register to comment.