Perfil de Santosh KumarSantosh Kumar Paruvella'...BlogListasLibro de visitasMás Herramientas Ayuda

Blog


30 julio

Dynamics Ax - AIF File system adapter Inbound common error

 

Common Error: Cannot be read because the submitting user could not be determined. The default owner for objects created by members of the Administrators group must be set to the object creator.

To avoid the above error do the following steps for file system adapters.

Before you create the folder for the inbound file system adapter on the server, complete the following:

1.               Click Start > Programs > Administrative Tools > Local Security Policy.

2.               On the Local Security Settings menu, navigate to Security Settings > Local Policies > Security Options.

3.               Change the Security Settings for the System Objects: Default owner for objects created by members of the administrator's group from Adminstrator's group to Object creator.

4.               Log off and log back on to the computer.

5.               Create the folder for the inbound file system transfer.

6.               Verify that the owner of the folder is the user sending the document to Microsoft Dynamics AX (the submitting user) by:

a.                           Right-clicking the folder and selecting Properties, and then

b.                           Clicking Advanced on the Security tab to view the Advanced Security Settings.

The owner of the folder is shown on the Owner tab.

 

After these settings are done place the XML file in that particular folder. Now run the AIF job to read the xml and to create the records in Dynamics – Ax.

Smile  Surprised

Dynamics Ax - AIF Web Service for AxdSalesOrder

 
 

Here I am going to give the sample application for consuming the AIF web Service in C#.Net.

 

For

1)        AIF setup and Generation of the web service

2)        how to take the reference of that service in VS application.

 

go through my previuos article.

 

http://paruvella.spaces.live.com/blog/cns!F2EC589E221A4DB0!114.entry

 

Then go through the following code for consume the AIF-SalesOrder web service using C# code in VS.Net.

 

namespace SalesOrderClient

{

    class MySalesOrder

    {

        static void Main(string[] args)

        {

            CreateSalesOrder();

 

            ReadSalesOrder();

           

        }

 

        static void CreateSalesOrder()

        {

            AxdSalesOrder so = new AxdSalesOrder();

            AxdEntity_SalesTable salesTable = new AxdEntity_SalesTable();

            AxdEntity_SalesLine salesLine = new AxdEntity_SalesLine();

 

            salesTable.CustAccount = "4000";

            salesTable.CurrencyCode = "USD";

            salesTable.DeliveryDate = new DateTime(2008, 20, 7);

            salesTable.Payment = "M15";           

 

            salesLine.ItemId = "BR-14";           

            salesLine.SalesQty = 20;

            salesLine.SalesUnit = "Pcs";

 

            salesTable.SalesLine = new AxdEntity_SalesLine[] { salesLine };

            so.SalesTable = new AxdEntity_SalesTable[] { salesTable };

            so.DocPurpose = AxdEnum_XMLDocPurpose.Original;

            so.DocPurposeSpecified = true;

 

// SalesOrderServiceContractClient is the proxy generated during the

//  reference of web service

           

SalesOrderServiceContractClient soService = new SalesOrderServiceContractClient();

 

            // makes a call to Create action on the Axd

 

            EntityKey ek = soService.createSalesOrder(so);

 

            Console.WriteLine("Creates Sales Order Id : " + ek.KeyData[0].Value);

 

 

        }

 

       

        static void ReadSalesOrder()

        {

            EntityKey ek = new EntityKey();

 

            KeyField kf = new KeyField();

            kf.Field = "SalesId";

            kf.Value = "00480_036";

 

            ek.KeyData = new KeyField[] { kf };

 

            SalesOrderServiceContractClient soService = new SalesOrderServiceContractClient();

 

            // makes a call to read action on the Axd

            AxdSalesOrder so = soService.readSalesOrder(ek);

 

            // Print the sales order read

            AxdEntity_SalesTable[] salesTables = so.SalesTable;

            foreach (AxdEntity_SalesTable salesTable in salesTables)

            {

                Console.WriteLine("Sales Order details :");

                Console.WriteLine("--------------------");

 

                string soName = salesTable.SalesName;                

                string custAccount = salesTable.CustAccount;

                AxdEnum_SalesStatus salesStatus = salesTable.SalesStatus.GetValueOrDefault();

 

                Console.WriteLine("Name             : " + soName);

                Console.WriteLine("Customer Account : " + custAccount);

                Console.WriteLine("Status           : " + salesStatus);

                Console.WriteLine("Purcase Order    : " + salesTable.PurchOrderFormNum);

 

 

 

                Console.WriteLine("Sales Line details :");

                Console.WriteLine("--------------------");

 

                AxdEntity_SalesLine[] salesLines = salesTable.SalesLine;

                foreach (AxdEntity_SalesLine salesLine in salesLines)

                {                    

                    string itemId = salesLine.ItemId;

                    string name = salesLine.Name;

                    decimal qty = salesLine.QtyOrdered;

                    decimal lineAmt = salesLine.LineAmount;

 

                    Console.WriteLine(" (1) ");

                    Console.WriteLine("Item Id      : " + itemId);

                    Console.WriteLine("Name         : " + name);

                    Console.WriteLine("Qty          : " + qty);

                    Console.WriteLine("Line Amount  : " + lineAmt);

                }

            }

 

        }

    }

}

25 julio

Dynamics Ax - Update the records with single query statement.

 

 

For updating the ‘N’ no. of records we can use simple query statement instead of using while loop.

(i.e. while select inventTrans where )

By using update_recordset we can update multiple records at a time.

 

oldRFQCaseId = this.orig().RFQCaseId;  

 

ttsbegin;

 

    update_recordset inventTrans

        setting TransRefId = this.RFQCaseId

            where inventTrans.TransRefId == oldRFQCaseId;

 

    ttscommit;

 

Secret telling

18 julio

Dynamics Ax - Use the Arithmetic Functions with query classes

 
Dynamics Ax - Using the Arithmetic functions with the query classes. Smile
 
Query                             query;
QueryBuildDataSource     queryBuildDataSource;
query = new Query();   
queryBuildDataSource = query.addDataSource(TableNum(AssetTrans));
queryBuildDataSource.orderMode(OrderMode::GROUPBY);  
queryBuildDataSource.addSelectionField(FieldNum(AssetTrans,amountMST), SelectionField::SUM);  
queryBuildDataSource.addSelectionField(FieldNum(AssetTrans,revaluationAmount), SelectionField::SUM);  
queryBuildDataSource.addSortField(FieldNum(AssetTrans, transType));   
queryBuildDataSource.addRange(FieldNum(AssetTrans,assetId)).value(rangeAssetId);   
queryBuildDataSource.addRange(FieldNum(AssetTrans,bookId)).value(rangeBookId);   
queryBuildDataSource.addRange(FieldNum(AssetTrans, transDate)).value(queryRange(dateFrom, dateTo));
    return query;
 
Result of the above Query: Hot SELECT SUM(AmountMST), SUM(RevaluationAmount) FROM AssetTrans GROUP BY AssetTrans.TransType ASC WHERE ((AssetId = FA-000001)) AND ((BookId = COMPUTERS)) AND ((TransDate<=12/31/2153))
 
Another simple query using the query classes.Tongue out
 
Query                             query = new Query();  
QueryBuildDataSource     queryBuildDataSource;
QueryBuildRange             queryBuildRange; 
 
queryBuildDataSource = query.addDataSource(tablenum(PurchParmTable));
queryBuildRange = queryBuildDataSource.addRange(fieldNum(PurchParmTable, Ordering));
querybuildrange.value(queryvalue(documentstatus::PackingSlip));
 
queryBuildRange = queryBuildDataSource.addRange(fieldNum(PurchParmTable, PurchId));
querybuildrange.value(queryvalue(purchparmtable.PurchId));  
 
queryBuildRange = queryBuildDataSource.addRange(fieldNum(PurchParmTable, ParmJobStatus));
querybuildrange.value(queryvalue('Executed'));
 
queryBuildRange = queryBuildDataSource.addRange(fieldNum(PurchParmTable, Invoiced));   
querybuildrange.value(queryvalue('No')); 
 
  this.query(query);
 
These are the simple examples using the query classes. Eye-rolling
 

Dynamics Ax - Display the form with different colors for a particular control value

 

Displaying the form for different colors for salesId based on sales status.


Create the form and add the combo box and change the enum type to SalesStatus and select the modified write the following code:
public boolean modified()
{
    boolean ret;
    ret = super();
    salesTable_ds.executeQuery();
    return ret;
}

and place the grid attach to the SalesTable and write the following methods on the form

public class FormRun extends ObjectRun
{
    QueryBuildrange     mySalesStatus;
}

public void displayOption(Common _record, FormRowDisplayOption _options)
{
    SalesTable prodtablelocal;
    prodtablelocal = _record;
    Switch(prodtablelocal.SalesStatus)
    {
    Case SalesStatus::Delivered:
    _options.backColor(65535); //Light Yellow
    _options.affectedElementsByControl(Salestable_SalesId.id());
    Break;
    Case SalesStatus::Invoiced:
    _options.backColor(8421631); //Light Red
    _options.affectedElementsByControl(Salestable_SalesId.id());
    Break;
    Case SalesStatus::Backorder:
    _options.backColor(65408); //Light Green
    //_options.affectedElementsByControl(Salestable_SalesId.id());
    _options.textColor(12582912);
    Break;
    }
}

public void executeQuery()
{
    ;
    if (comboBox.selection())
        mySalesStatus.value(QueryValue(comboBox.selection()));
    else
        mySalesStatus.value(" ");

    super();

}

public void init()
{
    super();

    mySalesStatus = this.query().dataSourceNo(1).addRange(fieldnum(SalesTable, SalesStatus));

    salestable_ds.executeQuery();
}

This different article from AIF.  Island with a palm tree    Smile

Dynamics Ax - update using AIF to get the Document Hash

In Dynamics Ax-2009 Document hash is mandatory to update the records using AIF. 

 \Classes\AxdBaseUpdate\deserializeTopEntity in this method  

The mandatory condition has been implemented, so that the document hash which is present in the XML and matches the current version in the Db. 

This Document hash is calculated based on the RecId and Recversion of the record. 

Here is the sample application for to get the hash code for a particular record. 

class MyHashCodeTest extends AxdBaseRecordInfo

{

    PurchRFQId     rFQId;

}

 public str getHashCode()

{

    AxdBaseUpdate               axdBaseUpdate  =  AxdbaseUpdate::construct();
    Map                                  dataSourceMap;
    Query                               query                   =  new Query(QueryStr(AxdRFQReply));
    AxdBaseRecordInfo        topAxdBaseRecordInfo;
    QueryRun                        _queryRun;
    str                                    documentHash;
    QueryBuildRange           qr;
    ;

     dataSourceMap = new Map(Types::Integer,Types::Integer) ;
    axdbaseUpdate.buildDataSourceParentMap(dataSourceMap, query.dataSourceNo(1)) ;
    query.dataSourceNo(1).addRange(fieldnum(PurchRFQReplyTable, RFQId)).value(rFQId); 

    _queryRun = new QueryRun(query); 

    topAxdBaseRecordInfo = AxdBaseRecordInfo::buildStructuredDocument(_queryRun, dataSourceMap);
    documentHash = topAxdBaseRecordInfo.getRecordHash();

    return documentHash;

}

public void new(Common _common, int _dataSourceId)
{

    rFQId = 0;

}

 void setRFQID(PurchRFQId _RFQId = '')
{

    ;
    rFQId = _RFQId;

}

Job to get the Hash - Code for update (By using above class): 

static void Job1(Args _args)
{

    MyHashCodeTest                            myHashCodeTest;
    PurchRFQReplyTable                      purchRFQReplyTable;
    str                                                    _hashcode;
   

    select * from purchRFQReplyTable where purchRFQReplyTable.RecId == 5637148795;
    myHashCodeTest  =  new MyHashCodeTest(purchRFQReplyTable, 1);
     myHashCodeTest.setRFQID(purchRFQReplyTable.RFQId);

    _hashcode             =  myHashCodeTest.getHashCode();   

    print _hashcode;
    pause;

}

Sample code to update the Document Hash in xml: 

    xmlDocument = new xmlDocument();   
   
xmlDocument.load("C:\\TestUpdate.xml");
    xmlNodeList = xmlDocument.getElementsByTagName('_DocumentHash');
    xmlNode = XmlNodeList.item(0);
    xmlNode.text(documentHash);         // This 'documentHash' got by using above class
    xmlDocument.save("C:\\TestUpdate_1.xml");


Smile 

 

 

 

11 julio

Dynamics Ax - AIF-Web Service

Creating and Consuming AIF Web Services

Pre-Setup
·         AOS, Client and BC.Net are installed
·         IIS is installed
·         ASP.NET 2.0 is enabled

Setup

·         Install AIF Web Services (Use All Defaults)
·         Open the AX Client
·         Add  a local end point

Basic -> Setup -> Application Integration Framework -> Local endpoints

Set Company as DAT and Local endpoint as localEndPoint

·         Add a web site

Basic -> Setup -> Application Integration Framework -> Web sites

Set the Name (Example: MicrosoftDynamicsAx) and Virtual directory share path to \\%MACHINENAME%\VirtualDirectory <file://%25machinename%25/VirtualDirectory>  Name (Example: \\paruvella\MicrosoftDynamicsAXAif50 <file://paruvella/MicrosoftDynamicsAXAif50> )

·         Generate the Service

Basic -> Setup -> Application Integration Framework -> Services

Select a service (Example: VendVendGroupService), click Enabled box, save and then click Generate button

Now I have the service generated (Example: http://paruvella/MicrosoftDynamicsAXAif50/VendGroup.svc)

 Consuming the Service with example code

·         Create a client in VS (Example: a console app named TestClient)

·         Add the service reference previously created, Optional: enter a namespace name (Example: VendGroupService)

·         Add the reference to System.ServiceModel. This will generate the proxy for VendGroup service

·         Added the following code in the Program.cs file

 C# Code :

namespace TestVendGroup
{
    class TstFIMVendGrp_ReadVendGroup
    {
        static void Main(string[] args)
        {
            VendGroupServiceClient proxy = new VendGroupServiceClient();
            AxdVendGroup vendGroup;
            EntityKey[] entityKeyList;
            EntityKey entityKey = new EntityKey();
            KeyField keyField = new KeyField();

            keyField.Field = "vendGroup";
            keyField.Value = "DOM";
            entityKey.KeyData = new KeyField[1] { keyField };
            entityKeyList = new EntityKey[1] { entityKey };         
            vendGroup = proxy.read(entityKeyList);     
            Console.Write(vendGroup.VendGroup[0].Name);
            Console.ReadLine();
        }
    }
}  

I started the writting blogs writting from today onwards.  Smile.

I will update my blog with more AIF related stuff. I am very much interest towards the AIF concepts. Red heart.