“Reversed” wild card search

Sometimes you would want to do a “reversed” wild card search, for example if you want to find out if a customer in any way matches a wild card stored in another table.

Here is a scenario:

You have a table and a form that stores customers that should be blocked in any way.
Here you can use the standard AX wild cards to indicate that a group of customers with partly the same name should be blocked.

Then, you want to find out if a specific customer should be blocked according to the table above.

Here is what you would need to do:

First of all you have to make sure that the table has the property CacheLookup set to ‘EntireTable’. Otherwise this wild card search won’t work.

Then, you can write this piece of code to check if the specific customer matches any of the wild cards in the table FO_BlockCustomer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
static void FO_ReversedWildCardSearch(Args _args)
{
    FO_BlockCustomer tblBlockCustomer;
    CustTable        tblCustTable = CustTable::find('DE-010');
    Name             name;
 
    if (tblCustTable)
    {
        name = tblCustTable.name();
 
        select firstOnly tblBlockCustomer where
        (name like tblBlockCustomer.Name);
 
        if (tblBlockCustomer.RecId)
            info(name + " should be blocked");
        else
            info(name + " should NOT be blocked");
    }
}

Checking customer ‘DE-010’ will return the following info log.

Leave a Reply

Your email address will not be published. Required fields are marked *