development methode per society

kenchykenchy Member Posts: 4
Hello all
First of all i'm french, so sorry for my bad english.

I start developping in navision, and i would like to show on form
for company 1 field 1
for company 2 field 2


actualy i use this:
IF STRPOS(COMPANYNAME,'comp1') > 0 THEN BEGIN
      CurrForm."field1".VISIBLE := TRUE;
      CurrForm."field2".VISIBLE := FALSE;
IF STRPOS(COMPANYNAME,'comp1') > 0 THEN BEGIN
      CurrForm."field1".VISIBLE := FALSE;
      CurrForm."field2".VISIBLE := TRUE;
](*,)


It is quiet heavy to past it in each form

So i wonder if there is a methode (using table, fonction, codeunit ...) to do this more cleanly [-o<

Comments

  • krikikriki Member, Moderator Posts: 9,110
    No, there is no other way.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • EugeneEugene Member Posts: 309
    you can pass table via RecordRef type variable but there is no analogous type for forms (could be named FormRef or something like that)

    So using RecordRef variables you could make fields non editable via undelying table's fields ENABLED property. Unfortunately table fields have no VISIBLE property
  • kenchykenchy Member Posts: 4
    A friend tel me to create un field in table Company Information
    and when i read this record in my form i put my condition.

    An other solution is to create a new table which contain company and field to show. So when i open form and read this table I test if this field exist and so I steal read in the table if i show it or not
  • EugeneEugene Member Posts: 309
    yes you can do either way but i thought your problem is - you do not want to copy-paste the same code into each form and instead you want to put a function in some codeunit and call it from all forms... There is no way to do the latter - i mean you cannot manage form's columns in a separate codeunit because there is no way to pass a form to codeunit's function.

    However i find the requirement to be very strange - why the view is dependent on a company selected ? It is mopre common when view is dependent on user and/or its role - for example company managers can see more or different information than accountants or sales persons and so on...
  • David_SingletonDavid_Singleton Member Posts: 5,479
    kenchy wrote:
    Hello all
    First of all i'm french, so sorry for my bad english.

    I start developping in navision, and i would like to show on form
    for company 1 field 1
    for company 2 field 2


    actualy i use this:
    IF STRPOS(COMPANYNAME,'comp1') > 0 THEN BEGIN
          CurrForm."field1".VISIBLE := TRUE;
          CurrForm."field2".VISIBLE := FALSE;
    IF STRPOS(COMPANYNAME,'comp1') > 0 THEN BEGIN
          CurrForm."field1".VISIBLE := FALSE;
          CurrForm."field2".VISIBLE := TRUE;
    
    ](*,)


    It is quiet heavy to past it in each form

    So i wonder if there is a methode (using table, fonction, codeunit ...) to do this more cleanly [-o<

    You need to explain WHAT you are trying to achieve, not HOW you want to achieve it.
    David Singleton
  • kenchykenchy Member Posts: 4
    ok
    I have two societies : S1 , S2, and one form F1, and two, fields C1, C2

    if the user select S1 and F1 he have to see C1 and not C2

    if the user select S2 and F1 he have to see C2 and not C1
  • David_SingletonDavid_Singleton Member Posts: 5,479
    kenchy wrote:
    ok
    I have two societies : S1 , S2, and one form F1, and two, fields C1, C2

    if the user select S1 and F1 he have to see C1 and not C2

    if the user select S2 and F1 he have to see C2 and not C1

    I meant what is the business requirement: What are fields C1 and C2 why do they need different fields for different companies?
    David Singleton
  • apertierraapertierra Member Posts: 61
    Is just needing to show a field or need also to input data in a field?
    Do they really need ot use two different fields or could they use the same field for both companies?
    If it's just displaying data, you can create a function that returns the value based on the company you are on, then just display that function.
Sign In or Register to comment.