Wednesday, December 15, 2010

Sending mail from workflow submit or Approve or any status in Dynamics Ax

During some period we are trying to send email from Ax while a workflow is submitted, approve or reject and etc. to the employee by using standard Ax procedure. But we did not achieve full our goal by using standard procedure. After few R&Ds we found that the standard Ax provides only can send a fixed email which is defined in E-mail template. Same mail has been sent to the user in case of workflow submit or approval or reject or anything. It is a standard template which is using in Ax.
Our requirement was different mail will go as per the workflow status. I found all the information are stored in the "Event Inbox" table. So I made a batch job class with necessary procedures and it is running into batch job after very little bit of customizations.

Customization:
1. One field is added into the "EventInbox" table: TMSendEmail (EDT: NoYesId)
 It would indicate email is sent or not. Once email sent then it will ticked.
2. Created a class with extends "RunBaseBatch"
 It prepares the email and send while batch occurrence in called

Procedure:
1. Set email id required employees those are tagged user in workflow
2. Check the email Notification field (under Approval & Task notification group)
   Administrator -> User -> User Option -> Notification (Tab)

Operations:
1. Find the class xpo and import it. Change the necessaries as per your requirements.
2. Run the class -> a dialog will open -> Select Batch Process -> click Recurrence
3. Set no "No End Date" and set recurring pattern to Minute in "1" under count filed
4. Click Ok to back
5. Put a caption and select a batch group from the Batch Group field then press OK.
Class automatically fall into batch job and it will call 1 every minute. You can find the batch job under Basic -> Enquiries -> Batch Job.
Here while the batch is call called then run method of class would call and corresponding methods will be executed.

Sending of mail to the user is depends upon the workflow configuration. Body, Subject, users all are to be set into the configuration.

I made it in this way if anyone have any idea or comment or suggestions then please don’t forget to share with me.

3 comments:

M D Amith Prasanna said...

Dear ,
I have configured Sales Credit approval Workflow & it is working fine .the thing is i have configured email notification , it is not working .i mean it is not sending notification email.please help me to find out what is the reason. thanks

Daniel said...

where is the xpo??

Anonymous said...

can u please share your class?