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

Announcements

No record found.

News and Announcements icon
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

  • Suggested answer
    Ghetz Profile Picture
    3,029 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,280 Super User 2026 Season 1 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans