Thursday, January 26, 2012

Accessing the URL of AxUrlMenuItem from AX into EP (Code behind)

Sometimes we need to change/append the URL defined on AXURLMenuitem in Dynamics AX 2012 in order to open different EP pages based on user selection. Here is the code to Create the complete URL in code (based On eb Menu Items)

     protected override void OnPreRender(EventArgs e)
        // Get the URL for the webpage that referenced the current record       
        AxUrlMenuItem url = new AxUrlMenuItem("EPSalesTableInfo");
        // update the hyperlink to point to the URL
        hpRecord.NavigateUrl = url.Url.ToString();

       // you can use this URL to redirect to any page like
       Response.Redirect(url.Url.ToString() + “&variable1=” +  stringvalue);