SETRANGE for Option type field

gumwitkagumwitka Member Posts: 34
Hi,

does anyone knows if I can use SETRANGE for fields that have option type?
Could you give me an example how to use it?

Kasia

Comments

  • JedrzejTJedrzejT Member Posts: 267
    Hi

    example:

    vendor.SETRANGE(vendor."Application Method",vendor."Application Method"::"Manual");
  • gumwitkagumwitka Member Posts: 34
    it does not work this way
  • JedrzejTJedrzejT Member Posts: 267
    this example should and must work

    Maybe there is other error. What do you trying to do?
  • costascostas Member Posts: 27
    As JedrzejT said it should work. You can also set a range like this
    SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type"::Order,SalesHeader."Document Type"::Invoice) or you can use the integer representation of the options like this
    SalesHeader.SETRANGE("Document Type",1,2).Note that options start from 0.
  • MbadMbad Member Posts: 344
    Abstain from using the number representation of the option unless its absolutely necessary(ie in variables used for multiple purposes). It conflicts with navision naming policy.
  • PhennoPhenno Member Posts: 630
    Mbad wrote:
    Abstain from using the number representation of the option unless its absolutely necessary(ie in variables used for multiple purposes). It conflicts with navision naming policy.


    Though, it is still represented as number.
    for example,
    you write SalesHeader."Document Type"::Order and "Order" is in position "3"
    in OptionString.

    If you add another option to the list with smaller position number (after wich, your "Order" option will be on position 4),
    your code will be "renamed" to option with position number 3.
  • jjanauskasjjanauskas Member Posts: 49
    btw, in standart navision code they never (or at least I don't remember) use SETRANGE for filtering several values of option field. They always use SetFilter(Field, '%1|%2|...', opt1, opt2, ...).
  • PhennoPhenno Member Posts: 630
    jjanauskas wrote:
    btw, in standart navision code they never (or at least I don't remember) use SETRANGE for filtering several values of option field. They always use SetFilter(Field, '%1|%2|...', opt1, opt2, ...).


    afaik, SETRANGE is for to set a "range" of values.

    wich means either "a" or ("a".."b")

    SETFILTER is used for advanced filtering with boolean operators, brackets etc...
  • jjanauskasjjanauskas Member Posts: 49
    Phenno, you are absolutely right, but in case when you want to filter the option field by range from opt1 to opt2, in standard navision they still enumerate all option values using SETFILTER, thus avoiding range specification :)
  • PhennoPhenno Member Posts: 630
    jjanauskas wrote:
    Phenno, you are absolutely right, but in case when you want to filter the option field by range from opt1 to opt2, in standard navision they still enumerate all option values using SETFILTER, thus avoiding range specification :)


    Probably cause of that "naming conventions"... if someone looks at the code, he/she probably don't know what options resides between opt1 & opt2...
Sign In or Register to comment.