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. :)
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. :)
Comments
Post a Comment