SPWorkflowTask.AlterTask抛出“不支持指定的方法”

时间:2010-06-30 01:38:40

标签: sharepoint sharepoint-2010 sharepoint-workflow

我正在尝试在新创建的Sharepoint任务上调用AlterTask,以向我的任务添加扩展属性,并抛出NotSupportedException。

发生了什么事?

2 个答案:

答案 0 :(得分:3)

新创建的任务实际上是SharePoint ListItem。 ExtendedProperties特别是工作流任务属性。

根据MSDN文档:

The content type of the item passed to the task parameter is not derived from the WorkflowTask content type.

这意味着在可以调用AlterTask方法之前,必须将表示新任务的SPListItem的内容类型设置为“工作流任务”:

    Dim selectedTaskList As SPList = web.Lists(taskListName)

    ' Create a new task item
    Dim newTask As SPListItem = selectedTaskList.Items.Add()

   ' Turn the new task item into a Workflow Task
    Dim newTaskContentType As Microsoft.SharePoint.SPContentType = web.AvailableContentTypes("Workflow Task")
    newTask("ContentTypeId") = newTaskContentType.Id

   ' Now the AlterTask method will work.  (assume you've alreade declared a hashtable of properties to set)
    Microsoft.SharePoint.Workflow.SPWorkflowTask.AlterTask(newTask, myHashTable, True)

答案 1 :(得分:0)

<div class="modal">
     <div id="target"></div>
</div>