Types of workflows
1. Sequential Workflow
2. State Machine Workflow
OOB workflows
1. Approval
2. collect feedback
3. collect signature
4. disposition workflow
In designer, workflow has actions, steps, conditions. It has workflow settings page where we have "Tasks" List, "workfow history" list. "Workfow history" list is not visible in "list and library" on SharePoint site, we have to access it through url <siteurl>/lists/workflow history/
We have "Information management policy" tag in "list/library settings" - one of the policy is called retention policy where we can define OOB/custom formula of date when we can archive items from the list to recyclebin/permanent delete/to other location and more. Activate SharePoint Server Enterprise Site Collection feature to use this functionality
There are 3 types of workflow in designer :
1.List workflow - This workflow is associated with a list and cannot be used anywhere. Save as templete option is disabled and cannot be published globally. So no *.wsp is created
2.Reusable workflow - This workflow is associated with contenttype. So if you attach contenttype to list/lib its corresponding workflow is also associated with it. You can save this workflow as template therefore *.wsp is created which is saved in Site Assets library. We can import this *.wsp file into VS 2010 and work on it further. If you have created this workflow in the subsite then u cannot publish it globally. Publish Globally mean publish in a site collection.
3.Site Workflow - This workflow is independent of list or contenttype. You have to manually start this workflow. We cannot save this workflow as template.
Visual Studio workflow: Sequential workflow starts with OnWorkflowActivated event which has different corelation token than OnTaskCreated, OnTaskChanged, OnTaskDeleted.
private void createTask1_MethodInvoking(object sender, EventArgs e)
{
createTask1.TaskId = Guid.NewGuid();
tasklistproperty = new SPWorkflowTaskProperties();
tasklistproperty.DueDate = DateTime.Now.AddDays(1.0);
tasklistproperty.AssignedTo = "waytous/rahul";
tasklistproperty.Title = this.workflowProperties.Item["Title"] + " Review";
tasklistproperty.ExtendedProperties["Comments"] = "Workflow has started...";
createTask1.TaskProperties = tasklistproperty;
}
private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
{
tasklistproperty = onTaskChanged1_AfterProperties1;
if (tasklistproperty != null)
{
if (tasklistproperty.PercentComplete == 1.0)
{
isTaskComplete = false;
this.workflowProperties.Item["Completion Status"] = "Review Completed";
}
else
{
SPListItem taskitem = this.workflowProperties.TaskList.Items.GetItemById(tasklistproperty.TaskItemId);
this.workflowProperties.Item["Completion Status"] = "Task Status " + taskitem["Status"].ToString() + " with " + tasklistproperty.PercentComplete.ToString();
}
this.workflowProperties.Item.Update();
duedate = tasklistproperty.DueDate;
}
}
For OnTaskChanged we have to 1st define afterproperties and beforeproperties in Property tab.
private void IsOnTime(object sender, ConditionalEventArgs e)
{
if (DateTime.Now.CompareTo(duedate) <= 0)
e.Result = true;
else
e.Result = false;
}
private void IsNotOnTime(object sender, ConditionalEventArgs e)
{
if (DateTime.Now.CompareTo(duedate) <= 0)
e.Result = false;
else
e.Result = true;
}
Ifelse statement u return the result back to e.Result.
No comments:
Post a Comment