D365 Finance & Operations and Dynamics AX Forum

Expand all | Collapse all

Launching an AX form from a button on a C# application

  • 1.  Launching an AX form from a button on a C# application

    TOP CONTRIBUTOR
    Posted 13 days ago
    ​Any advice on how to open an AX 2012 form by clicking a button on a WPF application that's written in C#?  The app needs to pass an AX sales order# to the custom AX form so that it autofills with info from the sales order when it renders.  Thanks in advance.

    ------------------------------
    Rudy Salcedo
    Senior Programmer/Analyst
    LaForce, Inc
    Green Bay WI
    ------------------------------
    Academy - Online Interactive Learning from Experts


  • 2.  RE: Launching an AX form from a button on a C# application

    Posted 12 days ago
    You can post a message on the standard named pipe that AX creates.

    Check the SysStartCmd* classes in AX (we created a new for our phone-system, based on *DrillDown)

    Then in C#, you might do something like:
    var cmd = "DrillDown_Phone/CustTable?Country=" + "" + "&Area=" + "" + "&PhoneNum=" + tbPhone.Text + "&Ext=";var cmd = "DrillDown_Phone/CustTable?Country=" + "" + "&Area=" + "" + "&PhoneNum=" + tbPhone.Text + "&Ext=";
    var pipeName = AXUtil.GenerateAxNamePipeUrl();

    using (var pipe = new NamedPipeClientStream(".", pipeName, PipeDirection.Out, PipeOptions.Asynchronous))
    {
        pipe.Connect(10000);
        var bytes = System.Text.UnicodeEncoding.Unicode.GetBytes(cmd);
        var bytesWithZero = bytes.Concat(new byte[] { 0, 0 }).ToArray();

        pipe.Write(bytesWithZero, 0, bytesWithZero.Length);
    }

    public static string GenerateAxNamePipeUrl()
    {
          string outPut;
          GetLogonSid(out outPut); //You need to get the SID of the user
          return "Dynamics\\Event\\0" + outPut;
    }

    Best regards,
    Kim

    ------------------------------
    Kim Dornonville de la Cour
    Demant
    Smørum
    ------------------------------

    Academy - Online Interactive Learning from Experts


If you've found this thread useful, dive deeper into User Group community content by role