I am creating a custom list in Visual Studio 2010 for SharePoint 2010.
I want to set "approvement needed" for single listitems to false or disabled.
My intention is, that a element can be approved or declined just one time, but not switch from "approved" to "not approved" to "approved" and so on
More detailed scenario:
- I've got a list of items that have to get reviewed after adding.
- If they get approved or declined it is a absolut decision and never should be changed
- If the item gets approved some events should be triggered
- If it gets declined a mail should be send!
My Ideas:
Idea - Workflow:
My first idea was to create a workflow which get fired after a ListItem added. The WF should create a task that could be reviewed. If it is positive it should fire some functions and deletes itself.
Idea- Workflow Design:
Idea- Workflow Code:
public Guid workflowId = default(System.Guid);
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
// these properties are for the workflow task that will be created.
public SPWorkflowTaskProperties CreateTaskApproval_TaskProperties = new SPWorkflowTaskProperties();
public SPWorkflowTaskProperties CreateTaskApproval_AffterTaskProperties = new SPWorkflowTaskProperties();
public SPWorkflowTaskProperties CreateTaskApproval_BeforeTaskProperties = new SPWorkflowTaskProperties();
public String CreateTaskApproval_ContentTypeId = default(System.String);
public Int32 CreateTaskApproval_ListItemId = default(System.Int32);
public Guid CreateTaskApproval_TaskId = default(System.Guid);
private void createTask1_MethodInvoking(object sender, EventArgs e)
{
createTask1.TaskId = new Guid();
// Now create the approval task.
// Set up some of the properties.
CreateTaskApproval_TaskId = Guid.NewGuid();
//Setting the task properties
CreateTaskApproval_TaskProperties.Title = "TestTitle"
CreateTaskApproval_TaskProperties.Description = "Description";
CreateTaskApproval_TaskProperties.AssignedTo = @"testemail\testuser";
CreateTaskApproval_TaskProperties.SendEmailNotification = false;
CreateTaskApproval_TaskProperties.TaskType = 1;
LogComment("Request Task Created.");
}
private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
{
//!!!! The Problem is here at Status
// Check to make sure the field is there on the item.
if (CreateTaskApproval_TaskProperties.ExtendedProperties["Status"] != null)
{
// Evaluate the value of the field.
if (CreateTaskApproval_TaskProperties.ExtendedProperties["Status"].ToString() == "Approved" || CreateTaskApproval_TaskProperties.ExtendedProperties["Status"].ToString() == "Declined")
{
TaskApproval_ApproveComplete = true;
}
else
{
TaskApproval_ApproveComplete = false;
}
}
}
private void completeTask1_MethodInvoking(object sender, EventArgs e)
{
workflowProperties.Item.ModerationInformation.Status = SPModerationStatusType.Approved;
//Fire some code here
}
Idea - Workflow- Problems: I can't get the tasks moderation status at all. ("approved" and so on)
CreateTaskApproval_TaskProperties.ExtendedProperties["Status"]
Does any on know how to?
Idea 2 Custom ASPX Page:
An other idea is to create an aspx page that lists all elements. So the user could approve with custom acctions! What about this idea? Is it practicable and a good alternative?