Same code over multiple lines

rzirpolorzirpolo Member Posts: 6
edited 2006-11-08 in Navision Attain
I am new to the Navision C/AL code so am learning this as I go along. I am trying to use the SETFILTER option but have noticed that there is a limit to how much code can be put on one line. I simply tried to continue it on a new line but I get a syntax error. The maximum code it lets me enter one line is,

SETFILTER("Customer No.",'<>CA16&<>CO05&<>EU05&<>EU100&<>EU101&<>EU102&<>EU11&<>EU21&<>EU26&<>EU28&<>EU30&<>EU36&<>EU44&<>EU46

On the next line it continues,

&<>EU47&<>EU72&<>EU79&<>EU92&<>GF04&<>IN14&<>IN17&<>IN26&<>IN53&<>IT08&<>RE42&<>TI04&<>TL01&<>TR27');

If I just use this which fits on the one line it compiles fine.

SETFILTER("Customer No.",'<>CA16&<>CO05&<>EU05&<>EU100&<>EU101&<>EU102&<>EU11&<>EU21&<>EU26&<>EU28&<>EU30&<>EU36&<>EU44&<>EU46');

Any help here would be greatly appreciated.

Comments

  • ara3nara3n Member Posts: 9,256
    you can use MARK to do the filtering. As for the code above this is how you can put it on multiple lines


    SETFILTER("Customer No.",'<>CA16&<>CO05&<>EU05&<>EU100&<>EU101&<>EU102&<>EU11&<>EU21&<>EU26&<>EU28&<>EU30&<>EU36&<>EU44&<>EU46' +'<>EU47&<>EU72&<>EU79&<>EU92&<>GF04&<>IN14&<>IN17&<>IN26&<>IN53&<>IT08&<>RE42&<>TI04&<>TL01&<>TR27');
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • rzirpolorzirpolo Member Posts: 6
    Superb, thank you very much. It's not the tidiest code in the world but at this point I just want to get it working.

    I have no documentation or help files so what is MARK ? do you have an example or a link to another forum ?

    Saying that a link to any help with syntax on Navision Attain would be a god-send. I can't seem to find any literature to help me out.
  • ara3nara3n Member Posts: 9,256
    On installation CD there are a couple of PDF. As for the Mark. here is an example


    if item.find('-') then repeat
      if Vendor.get(Item."Vendor No.") then
        Vendor.Mark(true);
    until item.next = 0;
    
    
    Vendor.MARKEDONLY(true);
    
    
    Message('there are ' + format(Vendor.count) + ' vendor that are selected on Item');
    


    Also in code hit F5 and look for all the variables. As for code examples, the whole navision is open.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • rzirpolorzirpolo Member Posts: 6
    After further consideration I realised I couldn't use these customer no's. So I now use this filter,


    SETFILTER("Invoicee Role",'APP - EXT FLEET MGMT|CAT|EXT|EXT FLEET MGMT|EXTERNAL FLEET MGMT|FLEET MANAGEMENT|FLEET SERVICES'
    +'FRANCHISEE|LEASE CO. (FIXED PR)|LEASE COMPANY|MANU (FIXED PR)|MANUFACTURER|OTHER|WARRANTY');

    It compiles fine but when I run it I get the error,

    "The filter 'APP - EXT FLEET MGMT|CAT|EXT|EXT FLEET MGMT|EXTERNAL FLEET MGMT|FLEET MANAGEMENT|FLEET SERVICES|'FRANCHISEE|LEASE CO. (FIXED PR)|LEASE COMPANY|MANU (FIXED PR)|MANUFACTURER|OTHER|WARRANTY' is invalid.

    You entered an inavlid expression in the filter....

    Do I need to enter anything different when using filters with spaces, fullstops, etc ?
  • ara3nara3n Member Posts: 9,256
    If you have prackets () you will need to put within single quotes '

    I strong suggest to use Mark.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Alex_ChowAlex_Chow Member Posts: 5,063
    Why not just create a new boolean field, mark these customers with this boolean field, then filter on teh boolean field?
  • SavatageSavatage Member Posts: 7,142
    We have several Vendors that offers Yearly discounts. Not all, so in the beginning we used to type out all the codes and it's a real pain.

    So another train of thought was if these customer/vendors all have something in common you can try & group them in another way either using say dimensions or creating you'r own custom field.

    Then you can filter on that really easily.
  • zeninolegzeninoleg Member Posts: 236
    And usually it is pretty bad to hardcode the values in the code. Navision is great because in it you can set up almost everything. What is going to happen if you will decide to add a customer to your filter or delete a customer.....going back to code writing. So I think deadlizard is right, you should create a new boolean field and filter buy it. And do not forget to add this field to the Customer Card, so users can change settings themselves
    Best Regards,
    Oleg
Sign In or Register to comment.