AX2012/D365FnO – HOW TO CREATE A INQUIRY FORM USING THE VIEW IN D365FnO

D365fno-PostImage

In this blog post, I will show you how to create a Inquiry using the View in D365FnO

In the previous blog post, we have discussed about View. In this post we will discuss about the Inquiry form development using View.

An inquiry form is a type of form that allows users to filter and view data from a Table, Query or View. It can also have buttons to perform actions on the records.

To create a inquiry from the view in D365FnO, you need to follow these steps:
1. Open Visual Studio and connect to your development environment (Model).
2. In the Solution Explorer, right-click the project and select Add > New Item.
3. In the Add New Item dialog box, select Dynamics 365 Items > User Interface > Form and enter a name for the Form.
4. Click Add to create the Form.
5. In the Form Designer, click on the Design | Pattern and set the pattern for the inquiry form (I have selected Custom as design pattern).
6. Set the data source for inquiry CustPaymMatchingInq in Table option, I have used View as data source. All fields are displayed under the Fields node.

8. Under Design | Pattern: Custom Add the FormGroup under this Group add FilterGroup for filtration and Grid for display the fields on the inquiry form.
9. Select  Design | Pattern: Custom node in Preview section you can see the structure of filtration and grid output.

10. Save your Inquiry and Build/Rebuild the project.

Copy & Paste the following code in the Form definition level for filtration and set the range on data.
[Form]
public class CustPaymMatchingInq extends FormRun
{
    // Condition for data filteration on the based of filters
    void filterData()
    {
        CustPaymMatchingInq_ds.query().dataSourceTable(tableNum(CustPaymMatchingInq)).clearRanges();
        if (Customer.valueStr())
        {
            CustPaymMatchingInq_ds.query().dataSourceTable(tableNum(CustPaymMatchingInq)).addRange(fieldNum(CustPaymMatchingInq,AccountNum)).value(Customer.valueStr());
        }
        if (FromDate.dateValue()    ||    ToDate.dateValue())
        {
            CustPaymMatchingInq_ds.query().dataSourceNo(1).addRange(fieldNum(CustPaymMatchingInq,TransDate)).value(queryRange(FromDate.dateValue(),ToDate.dateValue()));
        }
        CustPaymMatchingInq_ds.executeQuery();
    }
	
    // Called this method at the form initialization and set the From date & To date
    public void init()
    {
        super();
        FromDate.dateValue(dateStartYr(today())); // set current year start date as FromDate
        ToDate.dateValue(today()); // set today date as ToDate
        element.filterData();
    }
	
    // Override the Customer filter control level modified method and called the filterData() method
    [Control("String")]
    class Customer
    {
        public boolean modified()
        {
            boolean ret;
            ret = super();
            element.filterData();
            return ret;
        }
    }
    
    // Override the FromDate filter control level modified method and called the filterData() method
    [Control("Date")]
    class FromDate
    {
        public boolean modified()
        {
            boolean ret;
            ret = super();
            element.filterData();
            return ret;
        }
    }
	
    // Override the ToDate filter control level modified method and called the filterData() method
    [Control("Date")]
    class ToDate
    {
        public boolean modified()
        {
            boolean ret;
            ret = super();
            element.filterData();
            return ret;
        }
    }
	
    // Override the Clear filter button control level clicked method to clear the filters value
    [Control("Button")]
    class Clicked
    {
        public void clicked()
        {
            super();
            FromDate.dateValue(dateNull());
            ToDate.dateValue(dateNull());
            Customer.text('');
            element.filterData();
        }
    }
}

You can now test it by opening the inquiry from the display menu item. See output of inquiry form in the following screenshot.

That’s it! You have successfully created an inquiry form using view in D365FnO. I hope you found this blog post useful and informative. Share with others.
This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.