Wednesday, 22 May 2013

EP: C# Code to pass filter values to Dynamics ax interface class.

Code to pass filter values to Dynamics ax interface class.

///
    /// This method is used to pass parameters to Dynamics ax interface class.
    /// Parameters are passes as Menu URL.
    ///

    protected void ApplyFilter()
    {
        AxUrlMenuItem menuItem = this.getTargetURLMenuItem();
        menuItem.ExtraParams.Add("WP", RequisitionerName.Text);//1
        menuItem.ExtraParams.Add("WP", ProductCategoryRecID.Text);//2
        menuItem.ExtraParams.Add("WP", txtFromDate.Text);//3
        menuItem.ExtraParams.Add("WP", txtToDate.Text);//4
        menuItem.ExtraParams.Add("WP", LastmFDate);//5
        menuItem.ExtraParams.Add("WP", LastmTDate);//6      
        Response.Redirect(menuItem.Url.ToString(), true);
    }

X++ code: in Dynamics ax interface class method : initializeQuery()
 
 if (this.listPage() &&
        this.listPage().listPageArgs() &&
        this.listPage().listPageArgs().parameters() &&
        this.listPage().listPageArgs().parameters() != "")
    {
         menuItemName       =   this.listPage().listPageArgs().menuItemName();


        parameters          = this.listPage().listPageArgs().parameters();
        //retriving values from the container
        paramContainer      = Global::str2con(parameters);


        itemId                  = conPeek(paramContainer,1);//1 Product selection--> ItemID
        categoryRecID           = conPeek(paramContainer,2);//2 Product selection--> Product Cat
        rRdFromDate             = str2Date(conpeek(paramContainer,3), 213);//3 Requested receipt date--> From
        rRdToDate               = str2Date(conPeek(paramContainer,4), 213);//4 Requested receipt date--> To
        cRdFromDate             = str2Date(conpeek(paramContainer,5), 213);//5 Confirmed receipt date--> From
        cRdToDate               = str2Date(conPeek(paramContainer,6), 213);//6 Confirmed receipt date--> To
        oDdFromDate             = str2Date(conpeek(paramContainer,7), 213);//7 Ordering deadline--> From
        oDdToDate               = str2Date(conPeek(paramContainer,8), 213);//8 Ordering deadline--> To
        lineStatus              = conPeek(paramContainer,9);//9 Status--> Line Status
        lineAuthStatus          = conPeek(paramContainer,10);//10 Status--> AuthorizationStatus
        confirmShipTimeFrom     = str2time(conPeek(paramContainer,11));//11 Confirmed ship time--> From
        confirmShipTimeTo       = str2time(conPeek(paramContainer,12));//12 Confirmed ship time--> To

...

}

No comments:

How to Disable “Advanced Filter or Sort” and Enforce Custom Filters on Any D365FO Form

 In Dynamics 365 Finance and Operations, users can apply filters through the “Advanced filter or sort” feature found under the Options tab...