Use TableFilter field in SETVIEW

RnRRnR Member Posts: 21
Hi,

I've created a new table with rules to apply on the Customer table.

The new table includes a field of data type TableFilter which I have named Customer Filter. As a property I have set the field to link to TableIDExpr 18 (the customer table).

If I run the table and set a Customer Filter value of: Customer: No.=01000000...02000000
Then run a code in a codeunit:

myCustomerNo := 01000100;

r_Customer.GET(myCustomerNo);
r_Customer.SETVIEW(FORMAT(r_MyNewTable."Customer Filter"));
//IF a customer exists, I will alter some values for that customer..

An error occurs which sais: You cannot enter 'Customer: No.=01000000...02000000' in TableView.

Is it possible to use the tablefilter field to apply a filter to a record??

Comments

  • AdministratorAdministrator Member, Moderator, Administrator Posts: 2,500
    [Topic moved from NAV Tips & Tricks to NAV/Navision forum]
  • DuizyDuizy Member Posts: 8
    RecRef.SETVIEW(TableFilter2View(FORMAT("Table Filter")));


    TableFilter2View(TableFilter : Text[1024]) View : Text[1024]
    // TableFilter format:
    // <TableName>:<FieldCaption>=<FieldFilter>,<FieldCaption>=<FieldFilter>,..
    // View format:
    // [SORTING(<Key>)] WHERE(<FieldCaption>=FILTER(<FieldFilter>),<FieldCaption>=FILTER(<FieldFilter>),...)

    IF TableFilter = '' THEN
    EXIT('');

    View := 'WHERE(';

    FOR CharNo := STRPOS(TableFilter,':') + 1 TO STRLEN(TableFilter) DO BEGIN
    CASE TableFilter[CharNo] OF
    '=': View := View + '=FILTER(';
    ',': View := View + '),';
    '"':
    BEGIN
    CharNo := CharNo + 1;
    REPEAT
    View := View + FORMAT(TableFilter[CharNo]);
    CharNo := CharNo + 1;
    UNTIL TableFilter[CharNo] = '"';
    CharNo := CharNo + 1;
    END;
    ELSE
    View := View + FORMAT(TableFilter[CharNo]);
    END;
    END;

    View := View + '))';
Sign In or Register to comment.