My 2p about ERP Solutions, Information Worker Solutions and other software products (mainly Microsoft Dynamics AX and Microsoft SharePoint).

11 October 2012

Unwanted changecompany due to refresh SysOperationProgress class

Problem: unexpected changecompany

I was faced with a problem in Dynamics AX 2012, where sometimes an unexpected changecompany happened in a process. Sometimes it occurred, sometimes it didn’t, making it difficult to simulate it.

Solution

The cause of the problem was the SysOperationProgress class. This class can be used to inform the user about status, operation and progress of the system. It was initiated before my changecompany call and closed after it. When the progress bar created by the SysOperationProgress class was refreshed during code execution within my changecompany class, a call is done by X++ to the Docu class. This triggers also a changecompany due my original legal entity. Hence some of my code within my changecompany call was executed in the company to which I did the change, some was done in the company I originated from. And this not all of the time, as it only happened if a refresh happened of my progress bar within the changecompany call. I removed the SysOperationProgress and my problem was solved.


Continue reading......

by Patrik Luca 0 comments

10 October 2012

Create batch job through X++ code

Business requirement

Some flow should execute some code in batch, so you need to add a batch job for the corresponding RunBaseBatch class.

Solution


public static void scheduleBatch()
{
BatchHeader batchHeader;
BatchInfo localBatchInfo;
YourRunBaseBatchClass yourRunBaseBatchClass;
SysRecurrenceData sysRecurrenceData =
SysRecurrence::defaultRecurrence();
;

yourRunBaseBatchClass =
YourRunBaseBatchClass::construct();

// retry 3 times
sysRecurrenceData =
SysRecurrence::setRecurrenceEndAfter(
sysRecurrenceData, 3);
// retry after 1 minute
sysRecurrenceData =
SysRecurrence::setRecurrenceUnit(sysRecurrenceData,
SysRecurrenceUnit::Minute, 1);

localBatchInfo = yourRunBaseBatchClass.batchinfo();
localBatchInfo.parmGroupId("YourBatchGroupId");
batchHeader = batchHeader::construct();
batchHeader.addTask(yourRunBaseBatchClass);
batchHeader.parmRecurrenceData(sysRecurrenceData);
batchHeader.save();
}


Continue reading......

by Patrik Luca 4 comments

Patrik Luca, Ieper, BELGIUM
Feel free to use or spread all of the content on my blog. In return, linking back to my blog would be greatly appreciated. All my posts and articles are provided "AS IS" with no warranties.

Subscribe feeds via e-mail
Subscribe in your preferred RSS reader

Subscribe feeds rss Most Read Entries

Categories

Recommended Books


Subscribe feeds rss Recent Comments

This Blog is part of the U Comment I Follow movement in blogosphere. Means the comment field of this blog is made DOFOLLOW. Spam wont be tolerated.

Blog Archive

My Blog List

Followers

Links