Dynamics Search Engine

Tuesday, February 25, 2014

How to resolve CIL problem when it says Cannot create a record in SysXppAssembly (SysXppAssembly). The record already exists.

How to resolve CIL problem when it says Cannot create a record in SysXppAssembly (SysXppAssembly). The record already exists.

Sometimes you try to general incremental CIL or full CIL and receive error like "Cannot create a record in SysXppAssembly (SysXppAssembly). The record already exists." as shown below.



How to get out of this error?

The solution is simple. You need to restart the AOS.

Applied on: Dynamics AX 2012 R2
Prerequisite: Basic Dynamics AX 2012 knowledge

Target audience: AX programmers
Assumption: You are familiar with Dynamics AX 2012

Hope this was useful. You may leave your comments below.



 

Friday, February 21, 2014

How to resolve error Disconnected from the AOS for Microsoft Dynamics AX 2012 and Visual Studio .Net

Why you get error "Disconnected from the AOS" when you open Visual Studio and try to see Application Explorer tool box to customize something for Microsoft Dynamics AX Enterprise Portal or SSRS Reports?




Reason:

The Visual Studio instance you open does not refer the configuration which is configured. Such error you will encounter when you have different client and AOS system. For example; Server 1 is having Application Object Server (AOS) and System 1 is having AX client so you have AX client and server on different machines. Other way your Visual Studio instance is not connected to target Microsoft Dynamics AX AOS configuration.

Applied on: Dynamics AX 2012 R2

Prerequisite: Basic Dynamics AX 2012 knowledge
Target audience: AX programmers
Assumption: You are familiar with Dynamics AX 2012 and Visual Studio .Net


Solution:
Option 1: You should have AX client and server on the same machine. In general development server with multi users is not configured with single machine based.

Option 2: If your AX client and server are on different machines, you need to launch your Visual Studio instance using a shortcut from AX client machine and that shortcut should have target AOS configuration. E.g. You have an AX configuration file called VAR_DEV.AXC to launch the correct AOS. Get a shortcut of your Visual Studio on AX client machine right click on it. You will see the property dialog as shown below.


 

You will see the Visual Studio instance common IDE path [see above]. This is the default path. The depends based on installation.

The Target field should have path "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe". This is the default path.

The action you need to perform is to add target for AOS configuration file to it. To achieve this replace the path with "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" /AXConfig \\[File location]\DEV04_VAR.AXC


After modifying this value click on Apply button. Now you launch your Visual Studio by double clicking this Visual Studio Icon. It will allow you to see AOT objects as shown below.
 
 


Option 3: On AX client machine configuration utility you can upload configuration file DEV04_VAR.AXC. To do this, open Microsoft Dynamics AX 2012 Configuration Utility from Administrative Tools. Click on Manage button then Set Configuration Stone.



Click on Apply button then OK.

Now you can launch your Visual Studio on AX client machine from Start button > All Programs > Microsoft Visual Studio 2010 folder > Microsoft Visual Studio 2010.



Hope this was useful for you. You may leave your comments below.

 

Wednesday, February 19, 2014

How to call an AIF Service operation and send data outside Microsoft Dynamics AX 2012 using X++ code


Sometimes it happens like you developed an AIF Service in Microsoft Dynamics AX and not able to test. Reason can be anything. Consider a scenario where you need to send AX data outside using standard AIF services but don’t know how to send.
This article explains you how to run a read operation for an AIF Service to send data from Microsoft Dynamics AX to your destination folder using File System Adapter. This article may answer below questions:

Using X++ codes how to call a service operation for Microsoft Dynamics AX 2012 AIF?
How to call or execute read operation in Microsoft Dynamics AX 2012?
How to send data outside Microsoft Dynamics AX 2012 using Outbound?

How to use standard Microsoft Dynamics AX 2012 AIF Services?

Applied on: Dynamics AX 2012 R2
Prerequisite: X++; MorphX; Basic programming knowledge, Basic AIF
Target audience: AX programmers
Assumption: Outbound port is configured properly. The person has the basic idea about AIF.

Here I used a standard service call VendVendTableService and read operation of it to send Vendor data outside.

Below job is to select a vendor record and send to Queue Manager.

 
static void aifOutBoundServiceCall(Args _args)
{
    AxdSendContext      axdSendContext  = AxdSendContext::construct();
    AifEntityKey        aifEntityKey    = AifEntityKey::construct();
    Map                 keyData;
    AifConstraintList   aifConstraintList   = new AifConstraintList();
    AifConstraint       aifConstraint       = new AifConstraint();
    VendTable           vendTable;

    select firstOnly vendTable
        where vendTable.AccountNum == "‪‪V-1001";

    keyData = SysDictTable::getKeyData(vendTable);
    aifEntityKey.parmTableId(vendTable.TableId);
    aifEntityKey.parmRecId(vendTable.RecId);
    aifEntityKey.parmKeyDataMap(keyData);

    axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
    axdSendContext.parmSecurity(false);
    aifConstraint.parmType(AifConstraintType::NoConstraint) ;
    aifConstraintList.addConstraint(aifConstraint) ;


//To handle an error it can be checked if outbound port is configured. This is optional.
    AifSendService::submitDefault(  classnum(VendVendTableService),
                                    aifEntityKey,
                                    aifConstraintList,
                                    AifSendMode::Async,
                                    axdSendContext.pack());

}
 

Below logic can be used to check whether Outbound port is configure or not properly. It’s not mandatory but nice to have.
boolean canSendXML()
{
    boolean             ret;
    AifActionId         actionId;
    AifEndpointList     endpointList;
    AifConstraint       aifConstraint = new AifConstraint();
    AifConstraintList   aifConstraintList = new AifConstraintList();

    actionId = AifSendService::getDefaultSendAction(classnum(VendVendTableService), AifSendActionType::SendByKey);

 

    if (actionId)
    {
        aifConstraint.parmType(AifConstraintType::NoConstraint);
        aifConstraintList.addConstraint(aifConstraint);
 
        endpointList = AifSendService::getEligibleEndpoints(actionId, aifConstraintList);
 
        if (endpointList.getEndpointCount()>0)
        {
            ret = true;
        }
    }

    return ret;
}

 
To release data from Queue Manager below job can be executed.

static void aifOutboundExecutoinJob()
{
    new AifOutboundProcessingService().run();
    new AifGatewaySendService().run();
}

 
 
After execution of above job below is the output.
 

In Microsoft Dynamics AX, how to get a look up of all the tables available in AOT


This article explains you how to get a look up to a control for All the AOT tables and can answer to below relevant questions.
·  Create a look up to show all the tables from AOT.
·  How to develop a drop down to show all the AOT tables where user can select one among?
·  How to create an edit method in Microsoft Dynamics AX?


Applied on: Dynamics AX 2012 R2
Prerequisite: X++; MorphX; Basic programming knowledge
Target audience: Any

 
 


 












Output: Look up of all the AOT tables
  

Create a table with a single field. Here my table name is TableLookUp with field name TableObjID.
The field should be extended to RefTableId EDT as shown below.


Write an edit method to your table. I wrote a method in the name of tableObject2Name. The method looks like:


// This method returns table name
// BP deviation documented
edit TableName tableObject2Name(boolean _set, TableName _name) // System Documentation>Type>TableName
{
    Dictionary  dictionary;
    TableId     tableID;

    if (_set)
    {
        dictionary = new Dictionary();  // System Documentation>Classes>Dictionary
        tableID = dictionary.tableName2Id(_name);

        if (tableID)
        {
            this.TableObjID = tableID;
        }
    }
    return tableid2name(this.TableObjID);
}

 
Create a new form and use the table you created as data sources and method to get a control.
Here my form looks like:
 

<>