如何在sharepoint 2010 C#中获取任务列表的相关内容的价值?

时间:2014-08-11 17:28:22

标签: c# sharepoint

我们知道,工作流的任务列表有一个名为Related content的列。如何获取特定任务项的Related Content的值。我尝试了以下方式,但没有成功。

var campaignTaskList = currentWeb.Lists["CampaignTask"].Items;
var currentUserTaskList = (from SPListItem taskItem in campaignTaskList
                            let assignTo = new SPFieldUserValue(taskItem.Web, taskItem["Assigned To"].ToString())
                             where assignTo.User.Name == currentWeb.CurrentUser.Name
                             select taskItem).ToList();

     foreach (SPListItem workflowTaskItem in currentUserTaskList)
          {
             var item =  workflowTaskItem["Related Content"].ToString();
          }

1 个答案:

答案 0 :(得分:2)

Related Content字段声明:

<Field ID="{58DDDA52-C2A3-4650-9178-3BBC1F6E36DA}"
    Name="WorkflowLink"
    SourceID="http://schemas.microsoft.com/sharepoint/v3"
    StaticName="WorkflowLink"
    Group="_Hidden"
    Type="URL"
    DisplayName="$Resources:core,LinkField;"
    ReadOnly="TRUE"
    Sealed="TRUE">
</Field>

如何获取相关内容字段值

field Id

var relContent = item[SPBuiltInFieldId.WorkflowLink];

按字段名称:

var relContent = item["WorkflowLink"];