Monday, March 16, 2015

Ax 2012 AxLedgerJournalTrans.parmVoucher is not working well

If AxLedgerJournalTrans is used to insert a new line, the voucher value passed to parmVoucher() would not be saved. As the voucher value would be default from LedgerJournalTransType.determineDefaultVoucher().

Wednesday, February 18, 2015

AX 2012 TempDB Table joined in the form


Set the datasource linktype to be "inner join" for tempDB table to be joined in the form


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");
            }
        }
    }
}