RSS

Dynamics AX EP form in Edit and Insert mode

22 May

Generally when we worked on designing detail EP form we have two options to open EP form in Insert and Edit mode, either design two separate EP forms with same piece of code except Design mode property set to Inset or Edit. Different way is to create single EP form and write code behind to open form in either mode. to do this design your EP form and create two web menu items and set parameters as follows

mode=1 :- edit
mode=2 :- insert
Open your fom C# code behind and write following code:
    protected void Page_Load(object sender, EventArgs e)
    {
        this.SetupMode();
    }
    ApplicationProxy.EPFormAction FormMode
    {
        get
        {
            return (ApplicationProxy.EPFormAction)Convert.ToInt16(
            this.Page.Request.QueryString.Get(“mode”)); // This mode is the param set in web menu item url, i.e. mode=1
        }
    }
    private ISession AxSession
    {
        get
        {
            AxBaseWebPart webpart = AxBaseWebPart.GetWebpart(this);
            return webpart == null ? null : webpart.Session;
        }
    }
    private void SetupMode()
    {
        //Proxy.Info objInfoLog = new Proxy.Info(this.AxSession.AxaptaAdapter);
        //objInfoLog.add(Proxy.Exception.Warning, Convert.ToString(this.FormMode));
        switch (this.FormMode)
        {
            case ApplicationProxy.EPFormAction.EditMode:
                this.Form1.DefaultMode = DetailsViewMode.Edit;
                this.Form1.AutoGenerateEditButton = true;
                this.Form1.AutoGenerateInsertButton = false;
                break;
            case ApplicationProxy.EPFormAction.CreateMode:
                this.Form1.DefaultMode = DetailsViewMode.Insert;
                this.Form1.AutoGenerateEditButton = false;
                this.Form1.AutoGenerateInsertButton = true;
                break;
            default:
                this.Form1.DefaultMode = DetailsViewMode.ReadOnly;
                this.Form1.AutoGenerateEditButton = false;
                this.Form1.AutoGenerateInsertButton = false;
                break;
        }
    }

You are all set to see this dynamic behavior.  just to recap here are the steps:

  1. Design and deploy new form with default ReadOnly mode
  2. Create separate web menu items for Edit and Insert operations and set property Parameter=‘mode=1’ for Edit or ‘mode=2’ for insert.
  3. Get the session object by creating property AxSession
  4. Create FormMode() method in Form1.aspx.cs to get mode via a query string.
  5. Create SetupMode() method in Form1.aspx.cs
 
Leave a comment

Posted by on May 22, 2015 in Enterprise Portal

 

Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
365 by Thijs

Blogging about Microsoft 365, Azure and Automation!

axhowto

Blog about ax with sample codes, tips and tricks.

GM Dynamics Blogs

Transform IT with Digital Trasformation and Social Innovation

Ms. Dynamic Millennial

Unboxing Microsoft Dynamics 365 for Finance and Operations

DynaD365Power

Exploring the new vision of the Power platform

Dynamics Vision 365

The FinOps pulse

Breaking Bong

I write when no one is watching

ErpCoder

Microsoft Dynamics 365 Business Management Solution Enthusiast

Dynamics 365 Finance

Dynamics 365 Finance & Much More.

Microsoft Dynamics AX

“ANYONE WHO STOPS LEARNING IS OLD, WHETHER AT TWENTY OR EIGHTY.” —HENRY FORD

Sumit Potbhare

Dynamics 365 for Commerce

iotsolution.se

This is your site about D365 (Finance and Supply Chain Management), IoT (Internet of Things) and HoloLens

Omni 365

Dynamics 365 Finance and Operations Blog

DIY D365

Power Platform Done Your Way

%d bloggers like this: