Reputation: 10244
Firstly, I have created a custom list definition based on the Tasks list in Visual Studio. This feature also creates an instance of that list titled "My Workflow Tasks". Secondly, I have developed a custom workflow, again using Visual Studio. When I want to add my new workflow, I am not able to set My Workflow Tasks list to be used for workflow tasks. It is not listed in the drop-down of available lists that can be used.
Why is that? Could anyone explain what needs to be done in order to make it available? Thanks.
Upvotes: 1
Views: 6475
Reputation: 10335
Here is the code from AddWrkfl.aspx that populates the dropdown:
<select id="TaskList" name="TaskList" style="<SharePoint:EncodedLiteral runat='server' text='<%$Resources:wss,AddWrkfl_ListSelectionControlsStyle%>' EncodeMethod='HtmlEncode'/>" size="1" align="absmiddle" onchange="OnChangeSelectTaskList();">
<%
foreach (SPList list in Web.Lists)
{
if (list.BaseTemplate == SPListTemplateType.Tasks)
{
%>
<option value=<%SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(list.ID.ToString()),Response.Output);%>>
<% SPHttpUtility.HtmlEncode(list.Title,Response.Output); %>
</option>
<%
}
}
%>
<option id="OptCreateNewTaskList" value="" />
</select>
Based on this, the ListTemplate element of your custom list definition would need to have a Type attribute value of 107 in order to be displayed in the dropdown.
Alternatively, you could try associating your workflow to your list programmatically within a feature receiver:
SPWorkflowTemplate template = web.WorkflowTemplates.GetTemplateByName(
"My Workflow",
System.Globalization.CultureInfo.CurrentCulture);
SPWorkflowAssociation association = SPWorkflowAssociation.CreateListAssociation(
template,
"My Instance",
web.Lists["My Workflow Tasks"],
web.Lists["Workflow History"]);
list.WorkflowAssociations.Add(association);
Upvotes: 2