/// <summary> /// This method handle create task event /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void logTaskCreated(object sender, EventArgs e) { //Add Task Refs in the root site. using (DocumentApprovalTasks tasks = new DocumentApprovalTasks()) { using (SPWeb ObjRootWeb = SPHelper.GetRootWeb(SPHelper.GetRootUrl(workflowProperties.SiteUrl))) { //Getting Created By - Login Name SPFieldUserValue val = new SPFieldUserValue(workflowProperties.Item.Web, workflowProperties.Item["Created By"] as string); SPUser usr = val.User; string _documentAuthor = usr.LoginName; string initiationData = workflowProperties.InitiationData; // Getting Publishbale Location ID var Publish_Location_ID = from _value in XElement.Load(new StringReader(EscapeXml(initiationData))).Elements("Publish_Location_ID") select _value; string _locationID = string.Empty; foreach (var ID in Publish_Location_ID) { _locationID = ID.Value; } // Getting Publishbale Location Name var Publish_Location_Name = from _value in XElement.Load(new StringReader(EscapeXml(initiationData))).Elements("Publish_Location_Name") select _value; string _locationName = string.Empty; foreach (var Name in Publish_Location_Name) { _locationName = Name.Value; } SPFieldLookupValue _publishableLocation = new SPFieldLookupValue(Convert.ToInt32(_locationID), _locationName); ; //_publishableLocation=new SPFieldLookupValue(location //Getting Approver - Login Name string _taskUrl = workflowProperties.Item.Web.Url + "/Lists/DocumentApprovalTasks/DispForm.aspx?ID=" + CreateAppovalTask.ListItemId.ToString(); //Add Task Ref in the root site _documentApprovalTaskId = tasks.AddTask(CreateAppovalTask.TaskProperties.Title, CreateAppovalTask.TaskProperties.DueDate, CreateAppovalTask.TaskProperties.AssignedTo, _documentAuthor, _taskUrl, ObjRootWeb, _publishableLocation); //int _groupID = Convert.ToInt32(CreateAppovalTask.TaskProperties.AssignedTo.ToString().Split(';')[0]); SPGroup _approverGroup = ObjRootWeb.Groups[CreateAppovalTask.TaskProperties.AssignedTo]; //Send Email notification to the approver SendApproverEmail(_approverGroup, "CLIF"); } } LogToHistoryListActivity log = (LogToHistoryListActivity)sender; if (log != null) { log.HistoryDescription = "Document approval task created."; } }