Today I had a requirement that allow users to run Outlook synchronization process in batch rather sync it manually using out of the box functionality. Let's have a look on existing functionality and then extend it to achieve the requirement of running it in batch.
Existing functionality in AX
Home> Periodic > Synchronize [AOT form name is smmOutlookSyncrhonization]
As you can see someone has to manually sync outlook emails to AX acvitities or viceversa.
Extended functionality in AX
Let's implement this functionality in batch so users can set recurrence the Sync.
Create a new class;
Run this class by pressing F5,
Ooopsss!!! it throws an error
A
DialogStartGrp group is missing from the form smmOutlookSyncrhonization. In
this group dialog controls are added.
This requires to add a group on
the form and this has to have under a tab/tab page, let's do this;
How the current form
looks in AOT
How it should look like to use it for batch class, created above.
- Added new Tab
- Added new Tab page
- Added dialogStartGrp under tab page
- Moved exisiting groups under tab page
- Set caption "General" to tab page.
It requires few more
methods at form level to make it working in batch
public class
FormRun extends ObjectRun
{
HcmWorker
hcmWorker;
OutlookUserSetup outlookUserSetup;
TransDate
synchronizeFromDate;
TransDate
synchronizeToDate;
SyncOutLookEmails_RunbaseForm syncOutLookEmails_RunbaseForm;
}
public void
init()
{
synchronizeFromDate = systemdateget();
synchronizeToDate = systemdateget();
syncOutLookEmails_RunbaseForm =
element.args().caller().runbase();
super();
if
(!smmAxaptaOutlookMapping::isOutlookMappingSetupCompleted())
{
smmAxaptaOutlookMapping::createDefaultSetup();
}
// Find worker connected to the current logged ion
hcmWorker
= HcmWorker::find(HcmWorker::userId2Worker(curuserid()));
if (hcmWorker)
{
outlookUserSetup = OutlookUserSetup::findByWorker(hcmWorker.RecId);
// Calculate synchronization period based on the employee
setup parameters
activityFromDate.dateValue(systemdateget()
- outlookUserSetup.SmmSynchronizeDaysBack);
activityToDate.dateValue(systemdateget()
+ outlookUserSetup.SmmSynchronizeDaysForward);
}
else
{
// No employee is mapped to the current user. Set mapping
in Employee option form.
error("@SYS80637");
element.close();
}
}
void closeOk()
{
DialogRunbase dialog = element.args().caller();
;
dialog.updateServer();
if (syncOutLookEmails_RunbaseForm.checkCloseDialog())
super();
}
//AOSRunMode::Client
RunBase runBase()
{
return syncOutLookEmails_RunbaseForm;
}
Run class again by pressing
F5
Target achieved!!! You can run the form
with batch
Happy Dax!ng !!!
Thanks for your valuable post. Trying to do the same on AX2009 but I dont get how the synchronization can take place on batch server since the main class smmOutlookSync is forced to run on client side only. Also from your post I dont see smmOutlookSync getting called, so how the process is getting executed?
ReplyDeleteQUICK EASY EMERGENCY URGENT LOANS LOAN OFFER EVERYONE APPLY NOW +918929509036 financialserviceoffer876@gmail.com Dr. James Eric
ReplyDelete