Options

What does "::" operator do ???

emkproemkpro Member Posts: 47
I feel like a real dumb but I am really clueless, a searhed trough many of the codes in navision demo database still couldn't figure it out :roll:
Can anyone explain it to me ???
//EMK\\

Comments

  • Options
    KowaKowa Member Posts: 918
    edited 2004-12-17
    Hi,
    The :: is mostly used to access the Option Values of an Option Field in a Table by using their names.

    Internally these a stored as integer values, but the style guide does not allow to use the integers in the code directly ( though this will also work) because the code becomes less readable.

    It is also used to access the tables by name and not by their table ID
    for instance "DATABASE::Item" instead of "27" , when tables
    are used as function parameters.
    Kai Kowalewski
  • Options
    HalMdyHalMdy Member Posts: 429
    This operator is used with Option fields.

    For example, take Table 36-Sales Header
    Field Document Type.

    In your code, when you want to know wich type of Sales Header you have, you can write :

    IF "Document Type" = "Document Type"::Order THEN ...

    It's the same as :

    IF "Document Type" = 2

    but it's more readable ...
  • Options
    eromeineromein Member Posts: 589
    :: is called "scope"

    Options in Navision are stored as integer values. This means if you would have a field with the options Contact,Customer,Vendor these options are stores as 0,1,2. Note that options start at zero!

    So if you now want to set a filter on that field it would like like this:
    setrange(option, 1)
    

    As you see, this is not quite good to understand. That is way Navision invented the scope!

    You can "translate" the (interget) option value to "option::optionvalue"
    setrange(option, option::Customer)
    

    But be sure the variable / field is known. If not, refer to the right table. See below...
    salesheader.setrange(option, salesheader.option::Customer)
    
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Options
    emkproemkpro Member Posts: 47
    Thanks guys I thought it was something much more complicated :oops:

    Say can you give some details on this style guide please ?
    //EMK\\
  • Options
    KowaKowa Member Posts: 918
    emkpro wrote:
    Say can you give some details on this style guide please ?

    The style guide consists of several documents which determine how code, tables, forms and everything else in Navision should be designed in order to maintain the proper "look-and-feel" throughout the application. #-o
    Kai Kowalewski
  • Options
    AsallaiAsallai Member Posts: 141
    Hi All,

    Another question about "::", because I'd like to get value to option string.
    So the Input is a String what is IN(!) the target option field's value.
    (GETFILTER(Type))
    How can get this value for the option field?
    Because I don't like to generate a case function, if its this than do this...
    I'd like to get the simple value for the option field.
    Type := Type::GETFILTER(Type) or similar this. But this is not works of course. :(

    Thank you!

    A
  • Options
    kinekine Member Posts: 12,562
    May be better will be create new thread for that, else you can wait for answer too long. This thread is two years dead... :-)

    Answer: try this (if you have just one-value filter):
      EVALUATE(Type,GETFILTER(Type));
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    AsallaiAsallai Member Posts: 141
    Thanks kine,
    I know this thread was dead, but I don't want to open a new thread because the topic is same :lol:
    I tried this and works! Thanks again :D
    A
Sign In or Register to comment.