How To: Work around OnTaskCreated activity to get TaskId

Behavior/Symptoms:

  • OnTaskCreated activity was used to get taskid after executing createtask activity to send emails from sendmail activity along with task id, instead of sending an email using sendemailnotification=true from createtask activity.
  • sendemailnotification=true wasn't working for some reasons though timer was running fine.
  • After implementing OnTaskCreated activity at all places, WF gets locked at OnTaskCreated activity and resumes after 15-20 min.

Workaround:

  1. Remove the OnTaskCreated activity.
  2. Right click CreateTask activity, go to ListItemId property. Click on that field, It will open up the binding box. Select the second tab “Bind to a new member”, in that, provide the member name & below that select the “Create Field” option. Save & close.
  3. Drag & drop one CodeActivity after the CreateTask activity on your WF.
  4. Now in CodeActivity, you can access that field value which you defined in second step, that will contain the new TaskId which you want, to complete your functionality.