Posts

Showing posts with the label Dynamics AX 2009

Could not load file or assembly 'Microsoft.Dynamics.BusinessConnectorNet' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Image
Recently we were developing web service that that perform CRUD operation on AX 2009. We use business connector dll for this task. When we deploy app on IIS we start getting following error. Could not load file or assembly 'Microsoft.Dynamics.BusinessConnectorNet' or one of its dependencies. An attempt was made to load a program with an incorrect format. Dynamics AX .NET Business Connector contains both managed code and unmanaged 32-bit x86 code and as such it cannot be loaded by a 64-bit application. We resolved our issue by enabling 32 bit application in IIS. 1. Go to IIS. 2. Select you application pool. 3. Click Advance setting. 4. Set Enable 32-Bit Application to true.

X++ Tip And Tricks : Document Management Directory Does Not Exist

Image
I was working with Document Handling service in Microsoft Dynamics AX 2012. I faced weird error when i try to get attachment file "Document Management Directory Does Not Exists". After some diagnosis i have found that in Document Management Parameters the location to archive file was shared network location and because of AOS service account do not have permission to directory AX is throwing error. To resolve this error open Service.svc and check under which account your AOS service is running and give full permission to user account on shared directory path.

Unretreived Value In Form Field

Image
In Dynamics AX  2012 there is a problem in form data source that newly created field often not display data and "UnRetrieved" is display on the form. This error can be resolve by restarting AX or restating Dynamics AX 2012 service. When ever you crate new filed in table, you have to refresh the form so the new filed will be added in form datasource.

TTSCommit level

Image
Today i got this error when i try to run my code. Actually this error is telling that tts level in unbalanced and cant perform edit operations. To resolve this error this TTS level should be ZERO, Run this job to get rid of that error, this job will find the tts level where its greater than zero and make it zero by calling TTSABORT. tts b egin : marks the beginning of a transaction. This ensures data integrity, and guarantees that all updates performed until the transaction ends (by  tts c ommit  or  tts a bort ) are consistent (all or none). ttsCommit: marks the successful end of a transaction. This ends and commits a transaction. MorphX guarantees that a committed transaction will be performed according to intentions. static void TheAxaptaResetTTS(Args _args) { while (appl.ttsLevel() > 0) { info(strfmt("Level %1 aborted",appl.ttsLevel())); ttsAbort; } }

Calculate Age In Day, Months and Years in X++

I got required to display exact age of employee in days, month and years. I used some DateTimeUtil method and achieve my output. public static void getAge(Args args) { int years, months; int64 days; utcDateTime birthDayCurrentYear; str ageInWords; date _birthDate ; months = mthOfYr(systemdateget()) - mthOfYr(_birthDate); years = year(systemdateget()) - year(_birthDate); if (dayOfMth(systemdateget()) < dayOfMth(_birthDate)) { months--; } if (months < 0) { years--; months += 12; } #timeConstants birthDayCurrentYear = DateTimeUtil::addMonths(DateTimeUtil::newDateTime(_birthDate,0), ((years * 12) + months)); days = DateTimeUtil::getDifference(DateTimeUtil::newDateTime(systemdateget(),0) , birthDayCurrentYear) / #secondsPerDay; ageInWords = strFmt("%1 years, %2 months, days %3", years, months, days); info(ageInWords); ...

Business Connector Cache/Store Data In Memory

Image
During development in Dynamics AX 2009 and using business connector to get data from Dynamics AX i faced a problem that result were stored in cache and not reflecting the changes, to resolve this issue when i made changes on Dynamics AX i restart the AX service but after some time it stops working and it again not reflecting the changes, so i add following line of code in business connector code after logging in and it start working. Axapta ax = new Axapta(); ax.LogonAs(credentials.UserName, credentials.Domain, new System.Net.NetworkCredential(credentials.UserName, credentials.Password), null, null, null, null); ax.CallStaticClassMethod("SysFlushAOD","doFlush"); ax.CallStaticClassMethod(“SysFlushAOD”, “doFlush”);

Get Current User and Employe Infomation

Image
Retrieves the nonnumeric ID that represents the current user. curUserId(); Following function will return the name associated with the current user. XUserInfo::find(false, curUserId()).name; In order find out the employee linked to the current user. AX 2009: EmplTable::find(SysCompanyUserInfo::find(curUserId()).EmplId); AX 2012: HcmWorker::find(DirPersonuser::findUserWorkerReference(curUserId())).name();