Blue Theme Orange Theme Green Theme Red Theme
 
Team Foundation Server Hosting
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

How to get taskid in workflow for assigning task programmatically

 by Ravishankar on Mar 01, 2011

How to get taskid in workflow for assigning task programmatically
Comments: 0 Views: 2690 Printable Version 
Hi Friends,
I am posting my blog after long time. After busy schedule finally I got time post my blog.
In this blog I just want to share my experience that I faced while creating workflow and assigning task and sending the link to assign task programmatically.
My requirement was that I need to create task and send custom email body.In the body of email,I need to send a link for assign task.I googled the solution no success.Finally I tried with the below approach:

public static int GetNextAvailableIdFromList(SPSite site, Guid listId)

{

int NextAvailableId = -1;

if (site.WebApplication.ContentDatabases.Count > 0)

{

string DBConnString = site.WebApplication.ContentDatabases[0].DatabaseConnectionString;

SqlConnection con = new SqlConnection(DBConnString);

try

{

con.Open();

SqlCommand com = con.CreateCommand();

com.CommandText = String.Format("select tp_NextAvailableId from AllLists where tp_ID = '{0}'", listId.ToString());



NextAvailableId = (int)com.ExecuteScalar();

}

finally

{

con.Close();

}

}

return NextAvailableId;

}

Once You add the code in your workflow code file.You just need to call the method like below:

createTask_TaskProperties.EmailBody = workflowProperties.List.Title + " Request has been raised by " + workflowProperties.OriginatorUser.Name + " . Click "(ANCHOR TAG OPEN) href=\"" + workflowProperties.WebUrl + "/_layouts/WrkTaskIP.aspx?ID=" + Convert.ToString(GetNextAvailableIdFromList(workflowProperties.Site, workflowProperties.TaskListId)) + "&List=" + HttpUtility.UrlEncode(workflowProperties.TaskListId.ToString()) + "\">here to confirm the " + workflowProperties.List.Title.ToString();

createTask_TaskProperties.HasCustomEmailBody = true;

Thats Done..Try this.It will help you when you need that type of requirement. :)
Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 
Comments not available.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor

 Blogger's Profile
Age: Not Available
Location:
Title: Developer
Joined: Dec 16, 2010
Education: Bachelors Degree
 More Blogs from this Blogger
How to get taskid in workflow for assigning task programmatically
Issue and Fix for IE6 Fix
View all »
 Latest Blogs
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
The Euclidean Algorithm
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.