Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Setting filter for two different data for two fields

Posted on by 200

I need to filter "Transfer from code and transfer to code" for transfer order page
by two location fileds(service and sales filter in user management) not respectively. It should apply for both.
For first setfilter function its working.
SETFILTER("Transfer-to Code",'%1|%2',UserSetupMgt.GetServiceFilter,UserSetupMgt.GetSalesFilter);
but if i add the following code no data displays.
SETFILTER("Transfer-from Code",'%1|%2',UserSetupMgt.GetServiceFilter,UserSetupMgt.GetSalesFilter);
Is there any way to filter two fields with two different data at same time?
Thanks in Advance.

*This post is locked for comments

  • RE: Setting filter for two different data for two fields

    Thanks for your help in the code

  • RE: Setting filter for two different data for two fields

    Thanks Ghetz for your idea Its working...

  • Suggested answer
    4BzSoftware Profile Picture
    4BzSoftware 6,071 on at
    RE: Setting filter for two different data for two fields

    Hi Anandb313,

    I agree with Ghetz suggestion, mark and show needed records:

    Rec.RESET;

    IF Rec.FINDSET THEN

     REPEAT

       IF (Rec."Transfer-to Code"= UserSetupMgt.GetServiceFilter) OR (Rec."Transfer-to Code"= UserSetupMgt.GetSalesFilter)

         OR (Rec."Transfer-from Code"= UserSetupMgt.GetServiceFilter) OR (Rec."Transfer-from Code"= UserSetupMgt.GetSalesFilter) THEN

         Rec.MARK(TRUE);

     UNTIL (Rec.NEXT = 0);

    Rec.MARKEDONLY(TRUE);

  • Verified answer
    4BzSoftware Profile Picture
    4BzSoftware 6,071 on at
    RE: Setting filter for two different data for two fields

    Hi Anandb313,

    I agree with Ghetz suggestion, mark and show needed records:

    Rec.RESET;

    IF Rec.FINDSET THEN

     REPEAT

       IF (Rec."Transfer-to Code"= UserSetupMgt.GetServiceFilter) OR (Rec."Transfer-to Code"= UserSetupMgt.GetSalesFilter)

         OR (Rec."Transfer-from Code"= UserSetupMgt.GetServiceFilter) OR (Rec."Transfer-from Code"= UserSetupMgt.GetSalesFilter) THEN

         Rec.MARK(TRUE);

     UNTIL (Rec.NEXT = 0);

    Rec.MARKEDONLY(TRUE);

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,684 on at
    RE: Setting filter for two different data for two fields

    When you apply the filters on the fields it will apply the AND operation, if you want to do as OR operation then you need to do in two separate operations first apply the first filter retrieve and do your logic and then clear the filter and apply the  second filter on another field and then do your logic.

  • Suggested answer
    Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: Setting filter for two different data for two fields

    Please check this post: [View:https://community.dynamics.com/nav/f/34/t/268256:750:50]

    You can't do it directly, but there are workarounds. The downside is you need to loop through all the records. This is the answer I implemented:

    IF Rec.FINDFIRST THEN REPEAT
    
     IF (Rec.OutAgent = 'Bryan') OR (Rec.InAgent = 'Bryan') THEN
    
       Rec.MARK(TRUE);
    
    UNTIL Rec.NEXT = 0;
    
    Rec.MARKEDONLY(TRUE);

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... 290,902 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,336 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans