How to set a filter on an empty option string with C/SIDE?

PaLPiTaTioNPaLPiTaTioN Member Posts: 55
edited 2004-05-28 in Navision Attain
In CSIDE, I try to use this code:
IF "VAT-Type".Nummer = 1 THEN
    GLE2.SETFILTER("Gen. Posting Type",'%1',"Gen. Posting Type"::Purchase)
ELSE IF "VAT-Type".Nummer = 2 THEN
    GLE2.SETFILTER("Gen. Posting Type",'%1',"Gen. Posting Type"::Sale)
ELSE IF "VAT-Type".Nummer = 3 THEN
    GLE2.SETFILTER("Gen. Posting Type",'%1',"Gen. Posting Type"::" ");

I try to set the right filter on the field "Gen. Posting Type" of the G/L Entry-table. This field is an option field with three options: Purchase, Sale and '' (empty). Can anybody tell me how I should refer to the empty option value in my code? I now use " " because it's the only way to get the report compiling, but it seems to me that this is not the correct way to set the right filter.

Comments

  • kvbkvb Member Posts: 107
    but it seems to me that this is not the correct way to set the right filter.

    PaLPiTaTioN, it`s absolutely correct way :)
  • kvbkvb Member Posts: 107
    Another variant is to do like this:
    GLE2.SETFILTER("Gen. Posting Type",'%1', 2);
    

    Of course this code is correct only if OptionString for GLE2."Gen. Posting Type" is: Purchase, Sale,' '.
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    the optionString is:
    ,Purchase,Sale
    

    Mention the comma before Purchase, this one defines the empty value.
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    By the way, in the code I supplied, the third filter is set to
    "  "
    
    . the double quote normally defines a database field, so the compiler should expect a field, though I mean to set an empty string.
  • WarfoxWarfox Member Posts: 53
    why dont u use this :
    GLE2.SETrange("Gen. Posting Type",0);
    
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    Of course! I learned not to use this type of coding, but in this case it takes away the problem. And 0 is the first entry in the OptionString so you're absolutely right.
  • WarfoxWarfox Member Posts: 53
    Jea, is your problem now solved or do you have any more :wink:
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    i've got so many problems, but I won't disturb you with all of them :twisted:
  • nelsonnelson Member Posts: 107
    The first code example is the correct way to filter on an option field but you have to replace SETFILTER with SETRANGE and remove the %1.
    IF "VAT-Type".Nummer = 1 THEN
      GLE2.SETRANGE("Gen. Posting Type","Gen. Posting Type"::Purchase)
    ELSE IF "VAT-Type".Nummer = 2 THEN
      GLE2.SETRANGE("Gen. Posting Type","Gen. Posting Type"::Sale)
    ELSE IF "VAT-Type".Nummer = 3 THEN
      GLE2.SETFILTER("Gen. Posting Type","Gen. Posting Type"::" ");
    
    Nelson Alberto
  • PaLPiTaTioNPaLPiTaTioN Member Posts: 55
    and probably not usring
    "  "
    
    ", but
    ''
    
  • nelsonnelson Member Posts: 107
    No, you have to use " " with only 1 space.
    Nelson Alberto
  • RobertMoRobertMo Member Posts: 484
    If it compiles it is OK.
    And remember: Whenever there are spaces in "object qualifier" (variable name, field name, option value name...) object qualifier must be enclosed with double quotes.

    (one of the reasons why variable names are witohuot spaces, is that the code is more clear...)
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • jmjm Member Posts: 156
    Hallo,

    You can type
    GLE2.SETFILTER("Gen. Posting Type","Gen. Posting Type"::"0");
    in the C/AL-Editor and the compiler converts this to
    GLE2.SETFILTER("Gen. Posting Type","Gen. Posting Type"::" ");
    if the optionstring is
    ,Purchase,Sale

    br
    Josef
    br
    Josef Metz
Sign In or Register to comment.