Confirm Workflow Task
These examples show how to confirm a task using prefilled values.
Confirm a task
C#
using System.Collections.Generic;
using System.Linq;
using DocuWare.Platform.ServerClient;
namespace DocuWare.PlatformClientExamples
{
static partial class Examples
{
public static string ConfirmWorkflowTask(WorkflowTask task)
{
//load all decisions
task = task.TaskOperations.BaseTaskOperations.GetWorkflowTaskFromSelfRelation();
var firstDecision = task.Decisions.FirstOrDefault();
//it returns all fields and prefills in the decision
var fullLoadedDecision = firstDecision.DecisionOperations.BaseDecisionOperations.GetDecisionFromSelfRelation();
var confirmedData = new ConfirmedData()
{
ConfirmedFields = new List<ConfirmedField>()
};
foreach (var field in fullLoadedDecision.TaskFormField.Where(f=>f.Item.FormFieldType!= FormTypeEnum.Description && f.Item.FormFieldType != FormTypeEnum.Link))
{
confirmedData.ConfirmedFields.Add(new ConfirmedField()
{
Id = field.Item.Id,
Value = GetPrefilledFieldValue(field)
});
}
return fullLoadedDecision.DecisionOperations.ExtendedDecisionOperations.PostToConfirmRelationForString(confirmedData);
}
private static WFFormFieldValue GetPrefilledFieldValue(TaskFormField field)
{
switch (field.Item)
{
case KeywordsField keywordsField: return keywordsField.PrefillValue;
case TaskNumberField taskNumberField: return taskNumberField.PrefillValue;
case RoleField roleField: return roleField.PrefillValue;
case SubstitutionRuleField substitutionRuleField: return substitutionRuleField.PrefillValue;
case TaskDateTimeField taskDateTimeField: return taskDateTimeField.PrefillValue;
case TaskTextField taskTextField: return taskTextField.PrefillValue;
case UserField userField: return userField.PrefillValue;
default: return null;
}
}
}
}
Confirm a task asynchronously
C#
using System.Collections.Generic;
using System.Linq;
using DocuWare.Platform.ServerClient;
using System.Threading.Tasks;
namespace DocuWare.PlatformClientExamples
{
static partial class ExamplesAsync
{
public static async Task<string> ConfirmWorkflowTaskAsync(WorkflowTask task)
{
//load all decisions
task = task.TaskOperations.BaseTaskOperations.GetWorkflowTaskFromSelfRelationAsync().ConfigureAwait(false);
var firstDecision = task.Decisions.FirstOrDefault();
//it returns all fields and prefills in the decision
var fullLoadedDecision = await firstDecision.DecisionOperations.BaseDecisionOperations.GetDecisionFromSelfRelationAsync().ConfigureAwait(false);
var confirmedData = new ConfirmedData()
{
ConfirmedFields = new List<ConfirmedField>()
};
foreach (var field in fullLoadedDecision.Content.TaskFormField.Where(f => f.Item.FormFieldType != FormTypeEnum.Description && f.Item.FormFieldType != FormTypeEnum.Link))
{
confirmedData.ConfirmedFields.Add(new ConfirmedField()
{
Id = field.Item.Id,
Value = GetPrefilledFieldValue(field)
});
}
return await fullLoadedDecision.Content.DecisionOperations.ExtendedDecisionOperations.PostToConfirmRelationForStringAsync(confirmedData).ConfigureAwait(false);
}
private static WFFormFieldValue GetPrefilledFieldValue(TaskFormField field)
{
switch (field.Item)
{
case KeywordsField keywordsField: return keywordsField.PrefillValue;
case TaskNumberField taskNumberField: return taskNumberField.PrefillValue;
case RoleField roleField: return roleField.PrefillValue;
case SubstitutionRuleField substitutionRuleField: return substitutionRuleField.PrefillValue;
case TaskDateTimeField taskDateTimeField: return taskDateTimeField.PrefillValue;
case TaskTextField taskTextField: return taskTextField.PrefillValue;
case UserField userField: return userField.PrefillValue;
default: return null;
}
}
}
}