Thursday, August 25, 2011

TaskItem URL-sequen​tial work flow

string taskID = Convert.ToString(GetNextAvailableIdFromList(workflowProperties.Site, workflowProperties.TaskListId));


string constructURL = returnTaskUrl(taskID);


private string returnTaskUrl(string taskId)
{
string fulltaskUrl = string.Empty;
string htmlTaskLink = string.Empty;
try
{
//Use this to return the relevant URL's for use in e-mail of tasks.
string weburl = workflowProperties.WebUrl;
string taskUrl = "/_layouts/WrkTaskIP.aspx?List=";
string listId = workflowProperties.TaskListId.ToString();
fulltaskUrl = weburl + taskUrl + listId + "&ID=" + taskId;
htmlTaskLink = "here";
}
catch (System.Exception ex)
{
}
return htmlTaskLink;
}



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;
}



No comments:

Post a Comment

Popular Posts