Create a Simple AOT Job:
Our first task is to show the values of a table, which are to be printed in Infolog.
For aforementioned scenario, a new AOT JOB has to be created by following the steps below:
Open Dynamics AX and press crtl + D.
Then, right click on Jobs and create new JOB
Next step is to write query, which will show all the values of a table:
Select “HCMEmployment”
Since HcmEmployment table does not contain Employee name, one must use Join between "HcmEmployment" and “DirPerson” on RecID to create a joint relationship by entering following code.
Code:
static void
HN_AllEmp(Args _args)
{
HcmEmployment hcmEmployment;
DirPerson dirPerson;
while select
* from
hcmEmployment join dirPerson where HcmEmployment.RecID == dirPerson.RecId
{
info(strfmt("Employee
type '%1' and Name '%2'",hcmEmployment.EmploymentType,dirperson.Name));
}
}
Once coding process is completed, then click on "Play" button.
Congratulations!!! Now you have accomplished a simple example.
Next step is to update the values of a table while verifying that none of the values are negative.
Create new Table with single field int.
HNTableInt contains different numbers. So, create a query, which will produce a result of negative values ,but before updating the values, convert all the negative values into positive numbers, using absolute value (abs).
Code:
static void multiply(Args _args)
{
HNTableInt hNTableInt;
int a = 0;
ttsbegin;
while select forupdate Multiply from hNTableInt
{
a = a - 1 ;
hNTableInt.Multiply = abs(a) ;
hNTableInt.update();
info(int2str(hNTableInt.Multiply));
}
ttsCommit;
}
Have a nice day :)
thanks for the blog, Can you please tell me how do i schedule this job to run on specific data & time.
ReplyDeletethanks