I am sure most of you must be familiar with Batch jobs. If not created one, you must have at least seen some in action. A simple batch job consists of a single task with no dependencies. On the other hand, a complex batch job can have multiple tasks having dependencies with each other.
Basic info on how to create and run batch jobs can be found here.
http://msdn.microsoft.com/en-us/library/cc636647.aspx
In my post, I will demonstrate how to define dependencies between the tasks. This has application when you want to have complex dependency hierarchies, allowing you to schedule tasks in parallel, and choose multiple execution paths etc.
In short, I will create 2 tasks where second task will be dependent on the first task. Let's go step by step.
1. I am using the Tutorial_RunBaseBatch class. Just open/run the class, check the Batch processing checkbox and click OK. This will create a new batch job named Tutorial with one task.
2. Open the Batch job form. Select the newly created batch job named Tutorial. Click on View tasks button. You can see the only task available named Tutorial. Rename it to TutorialTask1 so that it makes more sense. Also, I kept a copy of Tutorial_RunBaseBatch class named CopyOfTutorial_RunBaseBatch. (I won't rename it as I am a little lazy. :P) Since each task represents a class, I will create a second task named TutorialTask2 running on CopyOfTutorial_RunBaseBatch class. Press Ctrl+N to create TutorialTask2.
3. Now select TutorialTask2, click the Has Conditions grid in the lower section of the Batch Tasks form and press Ctrl+N to create a new condition.
4. Select the task ID of the parent task, in our case TutorialTask1.
5. Select the status the parent task must have before the child/dependent task can run. In our case, TutorialTask2 starts when TutorialTask1 becomes 'Ended'. Save the condition.
It works more or less like a workflow. :)
Thanks to the popularity of Microsoft Dynamics AX (aka Axapta), there are tons of blogs containing useful insights and interesting facts on AX. The community is ever-growing and feels great to be a part of it. With this blog, I will add my two cents to the knowledge base and enforce my concepts as well. I will focus more on relatively unknown facts about AX as the fundamental aspects are thoroughly covered. So, let's begin.
Friday, January 6, 2012
Friday, December 23, 2011
UtilElements table
Being an AX developer, you must be familiar with .aod files. (For the uninitiated, .aod files contain all the application level code). Ever wondered, what is inside those .aod files, how the data is organised etc. Well, AX provides us a way to do just that. The answer lies in the UtilElements table.
This table forms part of the broader topic of Reflection APIs in AX. More on this later.
UtilElements table belongs to a set of Util prefix tables which contain all element definitions. In other words, these tables give you direct access to the content inside .aod files.
Lets see this table in action.
Suppose you want to find all classes beginning with Proj and that have been changed within the last month. One way to achieve this will be as follows.
You can also use the UtilElements table to find out objects belonging to a particular layer or maybe to fulfil a more specific requirement like listing all the static methods belonging to a particular table. For eg,
This table forms part of the broader topic of Reflection APIs in AX. More on this later.
UtilElements table belongs to a set of Util prefix tables which contain all element definitions. In other words, these tables give you direct access to the content inside .aod files.
Lets see this table in action.
Suppose you want to find all classes beginning with Proj and that have been changed within the last month. One way to achieve this will be as follows.
static void findProjClasses(Args _args)
{
UtilElements ue;
;
while select name from ue
where ue.RecordType == UtilElementType::Class
&& ue.Name like 'Proj*'
&& ue.ModifiedDateTime >
DateTimeUtil::addDays(DateTimeUtil::getSystemDateTime(), -30)
{
info(strfmt("%1", ue.Name));
}
}
You can also use the UtilElements table to find out objects belonging to a particular layer or maybe to fulfil a more specific requirement like listing all the static methods belonging to a particular table. For eg,
static void findStaticEmplTable(Args _args)
{
UtilElements ue;
while select name from ue
where ue.recordType == UtilElementType::TableStaticMethod
&& ue.ParentId == tableNum(EmplTable)
{
info(strfmt("%1", ue.name));
}
}
Wednesday, December 21, 2011
Repeatable read
This keyword can be used in cases where you merely want to read the record multiple times without any need to update. You use it like this.
select repeatableRead salesTable where salesTable.SalesStatus == SalesStatus::Invoiced;
On the database level, repeatableRead maintains a shared lock on all the records selected by the select statement, meaning that the records maintain the original values and no updates/deletes are allowed.
select repeatableRead salesTable where salesTable.SalesStatus == SalesStatus::Invoiced;
On the database level, repeatableRead maintains a shared lock on all the records selected by the select statement, meaning that the records maintain the original values and no updates/deletes are allowed.
Subscribe to:
Posts (Atom)