Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

How to check if field contains more than one filter

Posted on by 102

Hello. I have record and field. This field contains 1, 2, 3 or 4 location code filters. For example:

WHITE

WHITE|GREEN

WHITE|GREEN|RED

WHITE|GREEN|RED|BLUE

What is the most optimal (and simplest) way to check if number of location code filter is greater than 1?

I do this task in this way:

FilterTemp: Text

FilterTemp := Record.GetFilter("Location Code");

if FilterTemp.contains('|');

But im not sure that this is good way.

And how can I count number of Location Code filters in this example? I think I can count '|' in FilterTemp and result+1 will be correct answer. But maybe exists easier way?

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 72,895 Super User 2024 Season 2 on at
    How to check if field contains more than one filter
    Sorry for the late confirmation, hope the following helps.
    Dynamics 365 Business Central: How to check if there is only one value in the filter for a field (For example, check if number of G/L Account No. filter is greater than 1)
     
     
    Thanks.
    ZHU
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 72,895 Super User 2024 Season 2 on at
    RE: How to check if field contains more than one filter

    Hi, just adding some info.

    If only '|' is considered, I think a bug will occur.

    In fact we can also use "..." to filter the Location Code.

    For example,

    EAST..OWN LOG

    pastedimage1668579269069v2.png

    pastedimage1668579232952v1.png

    Hope this helps as well.

    Thanks.

    ZHU

  • Suggested answer
    DAnny3211 Profile Picture
    DAnny3211 9,272 Super User 2024 Season 1 on at
    RE: How to check if field contains more than one filter

    CIao

    you can use the following function

    learn.microsoft.com/.../text-split-list[text]-method

    check my answer if it was helpful, thanks

    DAniele

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,101 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,908 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans