Friday, November 28, 2014

AX 2012 EP - You cannot view data on this page because you are not a registered user in Microsoft Dynamics AX.

Error "You cannot view data on this page because you are not a registered user in Microsoft Dynamics AX. Contact your Microsoft Dynamics AX administrator." while trying to browse EP from the AX Client".

Solution - To make sure EP website application pool account is same as the business connector proxy account under
System administration -> Setup -> System -> System service accounts

Tuesday, November 18, 2014

AX 2012 AIF - Inbound Test

1. Write a script and test the required fields of XML
    VendInvoiceService  vendInvoiceService  = VendInvoiceService::construct();
    AifQueryCriteria    queryCriteria       = AifQueryCriteria::construct();
    VendInvoice         VendInvoice         = new VendInvoice();
    XmlDocument         xmlCreate;
    AifCriteriaElement  criteriaElement;
    str                 xml =   @'<?xml version="1.0" encoding="utf-8" ?>' +
                                @'<VendInvoice xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/VendInvoice">' +
                                @'  <VendInvoiceInfoTable class="entity">' +
@'    <PurchId>RA2-PO00000093</PurchId>' +
@'    <RANInvoiceLocationURL>PUR</RANInvoiceLocationURL>' +
@'    <RANInvoiceTotalInclTax>1500.01</RANInvoiceTotalInclTax>' +
@'    <InclTax>yes</InclTax>' +
                                @'    <CurrencyCode>AUD</CurrencyCode>' +
                                @'    <DocumentDate>2014-11-12</DocumentDate>' +
                                @'    <InvoiceAccount>3RDPA</InvoiceAccount>' +
                                @'    <Num>201411120301</Num>' +
                                @'    <PurchId>RA2-PO00000093</PurchId>' +
                                @'    <VendInvoiceInfoSubTable class="entity">' +
@'    <OrigPurchId>RA2-PO00000093</OrigPurchId>' +
                                @'      <VendInvoiceInfoLine class="entity">' +
                                @'        <Description>Tyler Describing stuff</Description>' +
@'    <OrigPurchId>RA2-PO00000093</OrigPurchId>' +
@'    <PurchaseLineLineNumber>1</PurchaseLineLineNumber>' +
@'    <RANDocumentId>201411120401</RANDocumentId>' +
                                @'        <ItemId>6310</ItemId>' +
                                @'        <ReceiveNow>3</ReceiveNow>' +
                                @'      </VendInvoiceInfoLine>' +
                                @'    </VendInvoiceInfoSubTable>' +
                                @'  </VendInvoiceInfoTable>' +
                                @' </VendInvoice>';

    criteriaElement = AifCriteriaElement::newCriteriaElement(tablestr(VendInvoiceInfoTable),
                                                             fieldstr(VendInvoiceInfoTable, Num),
                                                             AifCriteriaOperator::NotEqual,
                                                             '0');
    queryCriteria.addCriteriaElement(criteriaElement);

    try
    {
        xmlCreate = XmlDocument::newXml(xml);
        vendInvoice.deserialize(xmlCreate.xml());
        vendInvoiceService.create(vendInvoice);
    }
    catch
    {
        exceptionTextFallThrough();
    }

2. Configure the outbound port (field system adapter) with required fields


3. Create a class (extend AxSend) to generate the outboud record in the queue
     AxdSendVendInvoice      axdSendVendInvoice;
    AifConstraintList       aifConstraintList;
    AifConstraint           aifConstraint;

    axdSendVendInvoice        = new  AxdSendVendInvoice();
    aifConstraintList   = new AifConstraintList();
    aifConstraint       = new AifConstraint();

    aifConstraint.parmType(AifConstraintType::NoConstraint);

    aifConstraintList.addConstraint(aifConstraint);
    axdSendVendInvoice.parmShowDocPurpose(true);

    axdSendVendInvoice.sendMultipleDocuments(classNum(VendInvoice), classNum(VendInvoiceService), AifSendMode::Async, aifConstraintList);

4. Run the script to generate the xml file to outbound folder

    new AifOutboundProcessingService().run();
    new AifGatewaySendService().run();

Note: The sequence of the fields in the xml is very important
<?xml version="1.0" encoding="utf-8" ?>
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
<Header>
<MessageId>{E120D4F9-C466-4CBF-BA60-E365202D7B19}</MessageId>
<Company>RA2</Company>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/VendVendInvoiceService/create</Action>
</Header>
<Body>
<MessageParts>
<VendInvoice xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/VendInvoice">
  <VendInvoiceInfoTable class="entity">
    <CurrencyCode>AUD</CurrencyCode>
    <DocumentDate>2014-10-29</DocumentDate>
    <InclTax>Yes</InclTax>  
    <InvoiceAccount>3RDPA</InvoiceAccount>      
    <Num>TGC1</Num>
    <PurchId>RA2-PO00000093</PurchId>
    <RANInvoiceLocationURL>PUR</RANInvoiceLocationURL>
    <RANInvoiceTotalInclTax>1500.01</RANInvoiceTotalInclTax>
    <VendInvoiceInfoSubTable class="entity">
<OrigPurchId>RA2-PO00000093</OrigPurchId>
      <VendInvoiceInfoLine class="entity">
<Description>Tyler Describing stuff</Description>
<ItemId>6310</ItemId>
<OrigPurchId>RA2-PO00000093</OrigPurchId>
<PurchaseLineLineNumber>1</PurchaseLineLineNumber>    
<PurchPrice>500</PurchPrice>
<PurchUnit>ea</PurchUnit>    
<RANDocumentId>201411120401</RANDocumentId> 
<ReceiveNow>3</ReceiveNow>    
      </VendInvoiceInfoLine>
    </VendInvoiceInfoSubTable>
  </VendInvoiceInfoTable>
 </VendInvoice>
</MessageParts>
</Body>
</Envelope>

5. Configure the inbound port (Field system adapter) with required fields

6. Copy the xml files into inbound folder
Notes: The xml files would be deleted once the inbound service is run

7. Run the script to trigger the inbound services

    new AifGatewayReceiveService().run();
    new AifInboundProcessingService().run();

8. Check the records which should be created

Friday, November 7, 2014

AX 2012 - SSRS reports deployment timeout

Restart AOS, and deploy again.

AX 2012 DMF - Trigger the progress at the end of the DMF execution

If there is a process need to be trigger after the DMF execution, put the logic into postTargetProcess method of Entity class

And tick "Execute target step" to fire the postTargetProcess method

Wednesday, October 15, 2014

Ax 2012 TFS Auto Synchronization Script

A script to synchronize objects from TFS server

static void SysVersionControlSynchronization(Args _args)
{
    SysVersionControlSynchronization SysVersionControlSynchronization;
    SysVersionControlSyncParameters syncParm;
    SysVersionControllable controllable;
    SysVersionControlSystemFileBased sysVersionControlSystem;
    SysVersionControlTmpChange processedSyncElements;
    SysVersionControlSynchronizeBatchNum batchNum;
    Filename filename;
    SysVersionControlSynchronizeCommand command;
    boolean noInfo = false;
    Set folderSetSelected;
    Set folderSet;
    SetEnumerator folderSetEnum;
    Map resultMap;
    MapEnumerator mapEnum;
    boolean isVCSDefFile = true;
    SysTreeNodeContainer contControllable;
    RecordInsertList syncEntries;
    SysVersionControlFilebasedBackEnd backend;
    SysVersionControlRepositoryFolder   folder;
    int         i;
    container   folderCon = ["CUS"]; // model names to be syn
    ;

    SysVersionControlSynchronization = SysVersionControlSynchronization::construct();

    if (!SysVersionControlParameters::isVCSEnabled())
    {
        throw error("@SYS135983" + ' ' + strFmt("@SYS120745", "@SYS85914"), '', SysInfoAction_Formrun::newFormname(formStr(SysVersionControlParametersDev)));
    }

    if (versioncontrol &&
        versioncontrol.parmSysVersionControlSystem() &&
        !versioncontrol.parmSysVersionControlSystem().supportSynchronization())
    {
        throw error("@SYS112528");
    }

    // one batchNum for the whole syn
    batchNum = SysVersionControlSynchronizeLog::nextBatchNum();

    // When client synchronizes the VCSDef must be synchronized as well for getting latest
    // updates of models.
    versioncontrol.init();

    // Synchronize files for each folder
    for (i = 1; i<= conLen(folderCon); i++)
    {
        sysVersionControlSystem = versioncontrol.parmSysVersionControlSystem();

        if (sysVersionControlSystem)
        {
            // folder in the TFS client side
            folder = SysVersionControlParameters::find().RepositoryFolder + "\\" + SysVersionControlParameters::find().AppRoot + "\\" + conPeek(folderCon,i);

            syncParm = SysVersionControlSyncParameters::construct();
            syncParm.parmSilent(false);
            syncParm.parmForce(false); // To do , change here if "force" is required
            syncParm.parmDeleteLocalObjects(false);

            syncParm.parmSyncAll(true);

            // Evaluate if controllable is special for setting additional parameters.
            if (controllable && isVCSDefFile)
            {
                syncParm.parmSilent(true);
            }

            if (syncParm.parmSyncAll())
            {
                // Union the folders for models and additional folders
                folderSet = new Set(Types::String);
                folderSet.add(folder);
                backend = sysVersionControlSystem.parmBackend();
                // download the xpo files
                resultMap = backend.folderSetSynchronize(folderSet, syncParm);
            }

            // Process synchronized files
            if (resultMap) //Sync succeeded
            {
                mapEnum = resultMap.getEnumerator();
                syncEntries = new RecordInsertList(tableNum(SysVersionControlSynchronizeLog));

                while (mapEnum.moveNext())
                {
                    filename = mapEnum.currentKey();
                    command = mapEnum.currentValue();

                    controllable = SysVersionControlTmpItem::newControllable(sysVersionControlSystem.filename2ItemPath(filename), filename);

                    syncEntries.add(SysVersionControlSynchronizeLog::initLogEntry(
                            filename,
                            controllable,
                            command,
                            batchNum,
                            folder));

                    SysVersionControlTmpItem::releaseControllable(controllable);
                }

                // Commit sync-entries
                syncEntries.insertDatabase();

                if (resultMap.elements() && !syncParm.parmSkipImport())
                {
                    //
                    // Something to update
                    // Import xpos into AOT and then compile and synchornize
                    //
                    SysVersionControlSynchronizeLog::processBatchNum(batchNum);
                }

            }
            else
            {
                throw error("@SYS85688");
            }
        }
    }
}

Tuesday, September 23, 2014

Ax 2012 Management reporter - Installation Check Points

1. Run setup.exe from AX 2012 CU7 installation folder, and select components "Management reporter" and "Management reporter report designer"

2. Enter the AOS server and port numbers (Normally 2712 and 8201) which the management reporter would connect to.

3.Enter the database server name and select the Ax 2012 database (Not model database)

4. Enter AOS service account and password. This account should have "sysadmin" role in the database server

5. Enter Management report service port, configuration database name and data mart database name.
    Note 1: Make sure the port would not be blocked by firewall
    Note 2: Make sure the database names are not existing in database server
    Note 3: Make sure the database server has enough space for these two new databases

6. (Important) Enter integration account and password, and then enter the AX user id linked to this integration account.
     Note 1: Integration account must has "sysadmin" role in the database server
     Note 2: Integration account mush has a Ax user id created. And the Ax user id must have roles of "System administrator" and "Security administrator"

7. After the installation, we should be able to see the services are created and one Ax data mart is connected.


Possible error: There is no company is imported.
Reason: No company in the AX has ledger setup.
Solution: Configure the ledger setting for AX company

Possible error: The integration account does not have permissions.
Reason: 1. Management reporter only allow 4 free accounts without license. 2. Ax user (linked to integration account) does not have "security administrator" role
Diagnostic: Look at the "securtyUser" table in Management reporter configuration database.

Solution: Load the license from management reporter client and make sure ax integration user has "security administrator" role


 



Friday, September 12, 2014

Ax 2012 TFS - Client crash with error "AccessViolationException"

After TFS is configured for Ax 2012, occupationally, the Ax client would crash when we try to check out or get latest objects.

Solution:

1.  Delete the .AUC files under c:\users\username\AppData\Local
2.  Reset usage data  under Tools -> options
3.  Go to Version control -> synchronization log. And process the lines are not completed.


AX 2012 TFS - Temporary label files

After TFS is setup for AX coding version control, we would see a weird label id (like @$A) while we try to create a new label.












That's because the real label Id would not be assigned until the label is checked in.
Instead, there are temporary label files created with weird name. 
The files can be found under server application folder.

























In conclusion, if we see the weird label Id, it would be alright. No panic :-)

Wednesday, September 10, 2014

Ax 2012 Enterprise Portal - How to create EP proxies

In Ax 2012, a proxy need to be generated to call a table method from Enterprise portal.

Here, we are going to talk about how to create a proxy for the static method "webLookupItemidQuery" in "InventTable".

1. Open Visual Studio, and create new project



















2. Select project template "Class Library"

















3. After creating the project, right click the project to open the property panel and then change namespace to "Microsoft.Dynamics.Portal.Application.Proxy"
















4. Right click the project again to select "Add XXXX to AOT" (XXXX is the project name)



















The project would be able to be found under AOT -> Visual Studio Projects -> C Sharp Projects

5. Add the table to the project



















6. Finally, don't forget to set the project to be EP Proxy Project




















Once the proxy is created, the method can be called from EP pages.