I want to build a custom activity for SPD 2010 that can extract the full url of a workflow task.
I did not found something like this OOB. Did I missed something ?
I wrote the following code :
public Hashtable GetWorkflowTaskUrl(SPUserCodeWorkflowContext context, int taskItemId) { System.Diagnostics.Debugger.Break(); var result = new Hashtable(); result["Except"] = string.Empty; try { using (var site = new SPSite(context.SiteUrl)) { using (var web = site.OpenWeb(context.WebUrl)) { var list = web.Lists[context.ListId]; var item = list.GetItemById(context.ItemId); var wfInst = item.Workflows[context.WorkflowInstanceId]; var taskItem = wfInst.TaskList.GetItemById(taskItemId); result["EncodedAbsUrl"] = taskItem[taskItem.Fields.GetFieldByInternalName("EncodedAbsUrl").Id]; } } } catch (Exception exc) { result["Except"] = exc.ToString(); } return result; }
The code seems to work, as I can step into it. However, I'm struggling with the action.xml file :
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<WorkflowActions>
<Action Name="Extraire l'url de la tâche"
Category="Tâches"
Assembly="$SharePoint.Project.AssemblyFullName$"
ClassName="myproject.ListItemUrlResolver"
FunctionName="GetWorkflowTaskUrl"
AppliesTo="all"
UsesCurrentItem="true"
SandboxedFunction="true">
<RuleDesigner Sentence="Recherche l'url de la tâche d'ID %1 et la stocke dans %2">
<FieldBind Field="taskItemId"
Text="Task Item ID"
DesignerType="Default"
Id="1"
/>
<FieldBind Field="EncodedAbsUrl"
Text="Item url"
DesignerType="ParameterNames"
Id="2"
/>
</RuleDesigner>
<Parameters>
<Parameter Name="__Context"
Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions"
Direction="In"
DesignerType="Hide"/>
<Parameter Name="taskItemId"
Type="System.Int32, mscorlib"
Direction="In"
Description="Id de l'élément de liste"
/>
<Parameter Name="EncodedAbsUrl"
Type="System.String, mscorlib"
Direction="Out"
DesignerType="ParameterNames"
Description="Url absolu de l'élément"/>
</Parameters>
</Action>
</WorkflowActions>
</Elements>
Especially this :
<FieldBind Field="taskItemId"
Text="Task Item ID"
DesignerType="Default"
Id="1"
/>
I didn't find what I have to put in the DesignerType attribute :
- If I put "ChooseListItem", I can't choose my current task
- If I put "Default", I get an error telling me the default is not in the enumeration
- If I put nothnig, same error
What I simply want, is to be able to set the parameter to the current task id within a task process;
thx in advance