Home > Dynamics Ax > Dynamics Ax – update using AIF to get the Document Hash

Dynamics Ax – update using AIF to get the Document Hash


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

 ClassesAxdBaseUpdatedeserializeTopEntity
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 

 

 

 

Advertisements
Categories: Dynamics Ax
  1. venkat
    March 22, 2012 at 7:16 am

    Hai satosh this one you wrote on X++
    but i need in C#

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: