Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

Filter records in list page D365 Operations

Posted on by 1,022

Hi Experts,

I am using D365 Operations

Is it possible to customize to filter records in List page (InventTransferOrders). Basically, when a user opens the form(InventTransferOrders) , system should only display records for some of "From warehouse".

Thanks,

N.Sridhar

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Filter records in list page D365 Operations

    You could try to add this logic to your code:

    Check if sender.query().queryRun() exists. If it does, apply your range to sender.query().queryRun().query(). Else apply it to sender.query() like you already do.

  • Sridhar Narayanan Profile Picture
    Sridhar Narayanan 1,022 on at
    RE: Filter records in list page D365 Operations

    Hi,

    I could filter records based on users mapped to retail stores by writing piece of code in OnQueryExecuting event handler.

    System is displaying only filtered records at first instance.

    However, when user clears the filter manually on the field, the filter which was set using below code in OnQueryExecuting event handler is not working.

    [FormDataSourceEventHandler(formDataSourceStr(XXXPurchShipmentInterface, XXXPurchShipmentHeaderGrid), FormDataSourceEventType::QueryExecuting)]

        public static void XXXPurchShipmentHeaderGrid_OnQueryExecuting(FormDataSource sender, FormDataSourceEventArgs e)
        {
    
            SecurityUserRole        userRole;
            SECURITYROLE            securityRole;
            RetailChannelTable      retailChannelTable;
            RetailStoreTable        retailStoreTable;
            RetailStoreAddressBook  retailStoreAddressBook;
            DirAddressBookParty     dirAddressBookParty;
            HcmWorker               hcmWorker;
            DirPersonUser           dirPersonUser;
            InventParameters        inventParameters;
            RecId                   securityRoleRecord;
    
            select XXXSecurityRole from inventParameters;
            select RecId from securityRole where securityRole.AotName == '-SYSADMIN-';
            securityRoleRecord = securityRole.RecId;
            select RecId from securityRole where securityRole.Name == inventParameters.XXXSecurityRole;
            select SecurityRole from userRole where userRole.User == curUserId()
                && (userRole.SecurityRole == securityRoleRecord || userRole.SecurityRole == securityRole.RecId);
            if(!userRole)
            {
                while select XXXShipToCode from retailStoreTable
                join retailChannelTable
                where retailChannelTable.RecId == retailStoreTable.RecId
                join retailStoreAddressBook
                where retailStoreAddressBook.STORERECID == retailChannelTable.RECID
                join dirAddressBookParty
                where dirAddressBookParty.AddressBook == retailStoreAddressBook.AddressBook
                && retailStoreAddressBook.AddressBookType == RetailAddressBookType::Employee
                join hcmWorker
                where hcmWorker.PERSON == dirAddressBookParty.PARTY
                join dirPersonUser
                where dirPersonUser.PERSONPARTY == hcmWorker.PERSON
                && dirPersonUser.User == curUserId()
                {
                    sender.query().dataSourceTable(tableNum(XXXPurchShipmentHeader)).addRange(fieldnum(XXXPurchShipmentHeader, ShipToCode)).value		(retailStoreTable.XXXShipToCode);
                }
            }
        }
  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Filter records in list page D365 Operations

    Yes, it is possible. There are several options, and there are several things to consider before selecting the right option for you.

    Some questions:

    1) Which users?

    2) Which warehouses and how are they related to the users?

    Possible solutions in my own preferred order:

    1) Your users can create their own filters and save them. No development required.

    2) You can use xds to show only "relevant" warehouses to users, if there is some kind of link between the user and the warehouse(s) that you wish to show.

    3) You can modify the form in x++ to show only some warehouses to all users.  If you choose this option, you should create some new parameters to control which warehouses are shown and which are not. That enables the administrator to change the setting without further need for development.

    For all options you can find more information by searching the web.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,995 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,610 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans