How to Open a Filtered Form Using a Menu Item related to a row in D365FO

 I Will show you here how to Open a Filtered Form Using a Menu Item related to a row.

for example in Released Products i added a menu item to show Related PRQs to an item like this








Let's begin the development here:

first of all create a View with targeted Datasoruce and drag the field you need:



Next create Simple list form then add Datasource


Next override the form method "init" and write the following code:


    public void init()
    {
        InventTable selectedRecord;
        QueryBuildDataSource qbds;
        QueryBuildRange qbr;
 
        super();
 
        // Check if arguments are passed and if it's the correct type
        if (this.args() && this.args().record() && this.args().record() is InventTable)
        {
            // Get the selected record
            selectedRecord = this.args().record() as InventTable;
 
            // Get the QueryBuildDataSource for the second form's data source
            qbds = Oula_ItemRelatedPrq_ds.query().dataSourceTable(tableNum(Oula_ItemRelatedPrq));
 
            // Add a range based on the locationId field
            qbr = qbds.addRange(fieldNum(Oula_ItemRelatedPrq, ItemId));
            qbr.value(queryValue(selectedRecord.ItemId));
 
            // Execute the query to apply the filter
            Oula_ItemRelatedPrq_ds.executeQuery();
        }


    }



Now Attach the form to Display Menu

Finally add item menu button and make sure datasource is selected:



Done.Let me know if you have questions.







Comments

Popular posts from this blog

Develop embedded Powerbi Report from scratch in Dynamics365 F&O