When you are working with custom workflows implementing in Visual studio, you might be sending the emails when a task is created. By default SharePoint sends an email when a task is assigned to a user. But, if you want to customize the email body and subject, then you will use send mail activity and will give link to the user. Here the problem starts.
In CreateTask activity in Visual Studio you cannot get the taskID as the task is not yet created. What to do??? So, to get the task identifier we have to implement the below approach.
So, note that in custom workflows which are implementing through Visual Studio the only way you can get the TaskID is AfterProperties of the TaskCreated activity. I have wasted hours when I was learning these. Hope you liked it.
In CreateTask activity in Visual Studio you cannot get the taskID as the task is not yet created. What to do??? So, to get the task identifier we have to implement the below approach.
- CreateTask Activity
- TaskCreated Activity
- SendMail Activity
- OnTaskChanged Activity
- TaskComplete Activity
So, note that in custom workflows which are implementing through Visual Studio the only way you can get the TaskID is AfterProperties of the TaskCreated activity. I have wasted hours when I was learning these. Hope you liked it.
Using this approach means you can only send an email notification for a task when a task is completed. Thats pretty useless if you want to notify users of new tasks.
ReplyDeleteHi there,
ReplyDeleteI am sorry for the mistake. I was typing wrong TaskCreated and TaskCompleted in my post. Now, corrected. Thanks for pointing it out.
The blog was absolutely fantastic! Lots of great information and
ReplyDeleteinspiration, both of which we all need!b Keep 'em coming... you all do
such a great job at such Concepts... can't tell you how much I, for
one appreciate all you do!
Thanks Pravin for sharing information. I have used CreateTask activity but somehow its not sending email. I have created workflow from SPD and used Send Email action and that worked. What could be wrong ?
ReplyDeleteFirst thing as always, check your SMTP [This don't make any sense here as you are saying from SPD it is working.
ReplyDeleteSecond, try to set the task activity send mail option to true.
Third, explicitly use SendMail activity and try to send email.
thanks
-PRaveen.
Hi Praveen Iam getting an error when i use Infopath form as my custom Task Edit Form i was gettting an error when i try to edit the task form saying "The form you are attempting to open may be located on a different server. This form can only be opened using Microsoft InfoPath". Can you please help me to solve this issue.
ReplyDeletei have given the infopath form urn in elements.xml and changed the xsn deployment type to Elementsfile as in http://mstechsharing.blogspot.in/2012/03/sharepoint-2010-state-machine-workflows_2141.html