web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Setting filter for two different data for two fields

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Ghetz Profile Picture
    3,013 on at

    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);
  • Suggested answer
    Suresh Kulla Profile Picture
    50,247 Super User 2025 Season 2 on at

    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.

  • Verified answer
    4BzSoftware Profile Picture
    6,073 on at

    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
    4BzSoftware Profile Picture
    6,073 on at

    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);

  • anandb313@gmail.com Profile Picture
    200 on at

    Thanks Ghetz for your idea Its working...

  • anandb313@gmail.com Profile Picture
    200 on at

    Thanks for your help in the code

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans