Options

Lazy Programmers

Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
edited 2006-01-09 in NAV Tips & Tricks
Hi,

For all people who want clean programming but do not want to put in loads of text

If you compile
Form.runmodal(form::form1) 
OR
Form.runmodal(form::"1") 

It will generate
Form.runmodal(form::"Company Information")  

Same goes for reports and dataports etc.

Optionstrings:
SalesLine.Type := SalesLine.Type::"2"; 

Makes
SalesLine.Type := SalesLine.Type::Item; 

After compiling

Thanks to Alain Krikilion for the form::"1" tip :D

Comments

  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    You can also type
    Cust.Field1;
    

    Compiler makes:
    Cust."No.";
    
  • Options
    krikikriki Member, Moderator Posts: 9,096
    You can also type
    Cust.Field1;
    

    Compiler makes:
    Cust."No.";
    
    You forgot my "1"-tip. It also works for fields. :wink:

    or also
    Cust."1"
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    Timo_LässerTimo_Lässer Member Posts: 481
    If you have a field called "Table No." in your table and you want to check the value, many people use
    CASE Rec."Table No." OF
      36: [...]
      37: [...]
      38: [...]
      39: [...]
    END;
    
    It is better to write
    CASE Rec."Table No." OF
      DATABASE::"Sales Header":    [...]
      DATABASE::"Sales Line":      [...]
      DATABASE::"Purchase Header": [...]
      DATABASE::"Purchase Line":   [...]
    END;
    
    This also works with the trick
    CASE Rec."Table No." OF
      DATABASE::"36": [...]
      DATABASE::"37": [...]
      DATABASE::"38": [...]
      DATABASE::"39": [...]
    END;
    
    The compiler converts it into the correct code.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • Options
    garakgarak Member Posts: 3,263
    You can do this also with Option Fields:

    Optionfield = Salesperson/Team,Class,Main Group,Material Group,Info Group,Item

    VarOpt := Optionfield::S;
    VarOpt := Optionfield::c;
    VarOpt := Optionfield::"Mai";
    VarOpt := Optionfield::"Mat";
    VarOpt := Optionfield::"in";
    VarOpt := Optionfield::"it";

    Regards
    Do you make it right, it works too!
Sign In or Register to comment.