Unexpected Error when creating a new Workflow in AX 2012 R2

A colleague recently faced a problem regarding workflows in AX 2012 R2. When he tried to add a new workflow AX reported an error “An unexpected error has occurred while opening the workflow. See the event log on the AOS and contact your system administrator to resolve the issue.”  In a first step I added some code to Forms > WorkflowEditorHost > build() Method before the error is thrown to get the Stack and Exception Text

image

This revealed a problem with the services: “The communication object, System.ServiceModel.Channels. ServiceChannel, cannot be used for communication because it is in Faulted state.

image

Fortunately, such a problem can be solved with Default AX Voodoo. Generating Full IL and recreating the WCF configuration in the Dynamics AX Client Configuration Utility solved the problem.

Experience on Installing AX 2012 on Server 2012 RC

Right now Server 2012 has reached RTM but was not released yet. AX 2012 is not officially supported on Server 2012, however you may want to give it a try. Here is my experience installing AX 2012 FPP + CU3 on Server 2012 RC running SQL Server 2012 RTM.

Windows Server 2012

Install Windows Server 2012 with graphically UI. Use the new server manager to install .NET Framework 3.5 which is required for SQL Server 2012. Also install Windows Identity Foundation 3.5 which is required for SharePoint.

windows features

Install Domain Services, create a new domain an create user with password never expires. Create a new group policy and allow the sql users to logon as service.

  • sqlserver, sqlagent
  • aos, bcproxy, search
  • sharepoint, spservice
    sql gpo

SQL Server 2012

Install SQL Server 2012, you’ll require these features. When installing reporting services choose “install only” but don’t configure. During configuring installation provide the sqlagent account for the SQL Server Agent, bcproxy account for reporting services and sqlserver account for database services.

  • Database with Fulltext  (run as sqlserver)
  • Reporting Services (run as bcproxy)
  • Analysis Services
  • Management Tools
  • Data Tools (includes Visual Studio 2010 BI Studio) if don’t want to install VS 2012 full featured later

sql install

Dynamics Ax 2012

Download the latest Dynamics AX 2012 cumulative update (CU3) and patch your installation medium. This can be done by unzipping the ISO to a file share and copying the CU3 into the updates folder, see technet. The AX 2012 installer will recognize the updates in this folder and prompt you to accept the license terms. Also make sure to have the SQL Server 2012 hotfix for AX 2012 in the updates folder.

If you are using one of the demo data backups from Microsoft or if you use your own backup from another AX installation there are some things you have to take care of.

  • Update the Administrator users SID, Domain and Username in the UserInfo table
  • Delete old entries from the SysServerSessions table

SQL Server 2012 does no longer support the FIRSTFASTROW keyword which is used in the UtilElements and UtilIdElements view. You have modify the views SQL statement and delete any occurrence. The easiest way is to copy/paste the SQL Statement to notepad, replace “, FIRSTFASTROW” with “” and copy/paste the cleaned statement back to SQL Server.

ax FASTFIRSTROW

Install Dynamics AX 2012 AOS and client. Afterwards make sure to clean the BI Configurations and the Server configurations in AX (System Administration > Settings). Don’t forget to provide the bcproxy account as business connector account in system service accounts in AX.

Reporting Services

Installing Reporting Services is straight forward as you know from SQL Server 2008 R2. However, there are at least 2 prerequisites before the installation can succeed. You’ll need to install

  • Microsoft System CLR Types for SQL Server 2008 R2
  • SQL Server 2008 R2 Shared Memory Objects
    Start the SQL Server Reporting Services configuration manager. Make sure SSRS is running as bcproxy account. Follow the steps in the configuration tool, create databases, web services, report server manager and make sure there is no execution account provided in the Reporting Service configuration.

ax ssrs config

In Dynamics AX check if the SSRS configuration is valid and give it a try. Reporting should work properly

ax ssrs on w2k12

If you don’t have installed Visual Studio 2010 SP1 or SQL Server Data Tools yet, do this now. Install the development components, Debugger, Visual Studio Tools, Trace Parser and .NET Business Connector. Good news; these components should install and work without any additional steps. Try to create a simple report, deploy it to SSRS and call it from AX to verify your installation.

ax reporting

SharePoint Server 2010, Enterprise Portal and Enterprise Search

Here comes the tricky part, SharePoint out-of-the-box is not willing to install on server 2012. However, Mohamed Radwan has made a great video on youtube that guides you through the installation on server 2012. When you run the sharepoint installation configuration wizard, use the sharepoint account to access the database and the spservice account to run the services (like excel services).

As you know from other EP installation, you’ll need to register the bcproxy account as managed service account in sharepoint (central administration > Security > Managed Accounts). Create a new web application (application management > manage web applications > new). Use the bcproxy account to run this web application and make sure you don’t use any previous used TCP Ports by SSRS (e.g. 80). Don’t create a web site collection, the AX installer will do this for you. Start the Dynamics AX 2012 installer, and install EP. If you’ve done the SharePoint configuration correctly, AX will be able to install and configure EP for you. When you start AX and navigate to Home, you should the see the role center page.

ax ep

If you have installed SharePoint Server, all prerequisites for enterprise search should be fulfilled. Follow the Technet guide to install and configure enterprise search. Go to SharePoint Central Administration > Farm Services > SharePoint Server Search > Search Application > Content Source > Microsoft Dynamics AX and configure at least a daily full crawl.

search full crawl

Fazit

  • SQL Server 2012 RTM is working on Server 2012 RC and AX 2012 supports SQL 2012 RTM
  • Core Components are working on Server 2012 RC
  • Additional Components like SharePoint, Search Server etc. are tricky

Use Fulltext Index in AX 2012 to search in RSS feeds

Here is a simple example how to use the fulltext index capability in Dynamics AX 2012. This example downloads RSS postings into a table with fulltext index and runs a query to identify those with specific words.

Create the RssFeedTable

  1. Create a new String Extended Datatype called RssFeedId
  2. Create a new table called RssFeedTable and add the RssFeedId, Name and Uri
  3. Create a primary index based on the RssFeedId
  4. Set the RssFeedTable as Reference at the RssFeedId Extended
  5. Populate the table with data e.g.
    FeedId = technet
    Name = “Technet Austria”
    Uri = http://feeds.feedburner.com/TechnetTeamBlogAustria?format=xml

Create the RssContentTable

  1. Create a new Table called RssContentTable
  2. Add the RssFeedId, Description255 and rename it as Title and a Memo field
  3. Create a fulltext index for the memo field

image image

    Create the RSS Reader Class in C#

    1. Create a new Visual C# class library project for .NET 4.0 in Visual Studio
    2. Add the project to AOT
    3. Copy this code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ServiceModel.Syndication;
    using System.Xml;
    using System.Text.RegularExpressions;

    namespace ErpCoder.RssFeed
    {
        public class Reader
        {
            private string xmlAddress = String.Empty;
            private IEnumerator<SyndicationItem> enumerator;

            public Reader(string address)
            {
                xmlAddress = address;
            }

            public void Load()
            {
                var reader = new XmlTextReader(xmlAddress);
                var feed = SyndicationFeed.Load(reader);
                enumerator = feed.Items.GetEnumerator();
            }

            public bool Read()
            {
                return enumerator.MoveNext();
            }

            public string GetTitle()
            {
                return enumerator.Current.Title.Text;
            }

            public string GetDescription()
            {
                string text = Regex.Replace(enumerator.Current.Summary.Text,
                                             "<(.|n)*?>", String.Empty);
                return text;
            }       
        }
    }

    1. Set the Deployment Target at the project to Client: Yes and deploy

    Populate the RssContentTable

    1. Create a find method on the RssFeedTable
    2. Copy this code and substitute the parameter in the find method with one of yours

    static void populateFeedTable(Args _args)
    {
        System.Exception ex;
        RssFeedTable feedTable = RssFeedTable::find("techat");
        RssFeedContent content; 
        ErpCoder.RssFeed.Reader reader;
        InteropPermission permission;
     
        permission = new InteropPermission(InteropKind::ClrInterop);    
        permission.assert();

        try
        {
            reader = new ErpCoder.RssFeed.Reader(feedTable.Uri);
            reader.Load();

            while(reader.Read())
            {
                content.clear();
                content.Title = reader.GetTitle();
                content.Text = reader.GetDescription();
                content.FeedId = feedTable.FeedId;
                content.insert();
            }
        }
        catch(Exception::CLRError)
        {
            ex = CLRInterop::getLastException();
            error(ex.get_Message());
        }

        CodeAccessPermission::revertAssert();
    }

    Create a job to test the fulltext index

    1. Create a new job and copy this code

      static void queryFullText(Args _args)
      {
          RssFeedContent feedContent;
          Query query = new Query();

          QueryBuildDataSource qbdsContent =
           query.addDataSource(tableNum(RssFeedContent));

          QueryBuildRange rangeText =
           qbdsContent.addRange(fieldNum(RssFeedContent,Text),
                                1,QueryRangeType::FullText);
          QueryRun queryRun;
          rangeText.value("Office Hyper-V");

          queryRun = new QueryRun(query);
          while(queryRun.next())
          {
              feedContent = queryRun.get(tableNum(RssFeedContent));
              info(feedContent.Text);
          }
      }

    2. Subsitute the value of the fulltext range value with yours
    3. Test the query

    image