SETFILTER on an option string

I have to set a filter on an option string but it gives me an error....
I'm trying this:

TB1.SETFILTER("Customer Type",'<>%1','Business');

but it says that the type conversion is not possible..... please help me!

Best Answer

Answers

  • sharon95sharon95 Member Posts: 183
    Thanks, now I want to write an if statement on the same table....

    IF AddressG."Customer Type" = 'Male' THEN BEGIN

    but it doesn't work...
  • sharon95sharon95 Member Posts: 183
    sharon95 wrote: »
    Thanks, now I want to write an if statement on the same table....

    IF AddressG."Customer Type" = 'Male' THEN BEGIN

    but it doesn't work...

    and also make an assignment like
    IF AddressG."Customer Type" = 'Male' THEN BEGIN
    AddressSurnameG."Customer Type"::"Male";
  • KishormKishorm Member Posts: 921
    Use similar format...
    IF AddressG."Customer Type" = AddressG."Customer Type"::"Male" THEN BEGIN
    
  • RockWithNAVRockWithNAV Member Posts: 1,139
    Use this

    IF AddressG."Customer Type" = AddressG."Customer Type"::"Male" THEN BEGIN

    OR ELSE

    IF AddressG."Customer Type" = 3 (Integer Value)
  • KishormKishorm Member Posts: 921
    Please do not use "IF AddressG."Customer Type" = 3 (Integer Value)" - it is widely accepted that this is bad practice and makes code difficult to read/understand. I know it exists in a few places in standard NAV code but that doesn't mean we should do it. Imagine if the posting routines (e.g. CU 12, 22) used this format - it would be a nightmare to try to understand that code.
  • Mohit_B1Mohit_B1 Member Posts: 13
    Dear Sir ,

    i want to Generate Sales Register by using Location filter , posting Date filter and Tax type Filter .
    Location And Posting filter successfully working but tax type filter not work.
    code like :-1: RecPurchaseHeader - OnPreDataItem()
    RecCompany.GET;
    TxtDateFilter := '';
    txtLocationfilter :='';



    IF RecPurchaseHeader.GETFILTER("Posting Date") <> '' THEN
    TxtDateFilter := 'Purchase Period ' +RecPurchaseHeader.GETFILTER("Posting Date")
    ELSE
    TxtDateFilter := 'Purchase Register';

    IF RecPurchaseHeader.GETFILTER("Location Code") <> '' THEN
    txtLocationfilter := 'Location Filter :- ' +RecPurchaseHeader.GETFILTER("Location Code")


    IF recdetail.SETFILTER("Tax Type",'<>%1',"Tax Type"::'CST') THEN
    txtCSTVAT := 'CST Filtering ' + RecDetails(RecDetails."Tax Type"::CST)
    ELSE
    txtCSTVAT := 'CST Filtering ' + RecDetails(RecDetails."Tax Type"::VAT);
  • KishormKishorm Member Posts: 921
    @Mohit_B1 - The last IF statement should be something like this...
    recdetail2."Tax Type" := recdetail2."Tax Type"::"CST";    // NOTE - new record variable required here
    IF recdetail.GETFILTER("Tax Type") = FORMAT(recdetail2."Tax Type") THEN
    

    ...Note you need to create a new variable recdetail2 because in most versions of NAV FORMAT("Tax Type"::"CST") would give you the positional value as a text and not the option value as a text

    P.S. You should not hijack an existing post like this - you should create your own separate post
  • Mohit_B1Mohit_B1 Member Posts: 13
    thanks your feedback Sir i will try ......
Sign In or Register to comment.