【问题标题】:Not able to start List Sharepoint 2010 Platform workflow using CSOM无法使用 CSOM 启动 List Sharepoint 2010 Platform 工作流
【发布时间】:2015-02-24 16:28:24
【问题描述】:

我正在使用 CSOM 启动与 List 关联的 SharePoint 2010 平台工作流。由于这是在 SharePoint 2013 Online 中创建的 SharePoint 2010 工作流,因此我使用的是工作流 InteropService StartWorkflow 方法。

Web web = clientContext.Web;
WorkflowServicesManager manager = new WorkflowServicesManager(clientContext, web);
InteropService workflowInteropService = manager.GetWorkflowInteropService();
clientContext.Load(workflowInteropService);
clientContext.ExecuteQuery();

List sharePointList = web.Lists.GetByTitle("Ronak");
ListItem sharePointListItem = sharePointList.GetItemById(1);
clientContext.Load(sharePointList);
clientContext.Load(sharePointListItem);
clientContext.ExecuteQuery();

Guid itemGuid = Guid.Empty;
if (sharePointListItem.FieldValues.ContainsKey("UniqueId"))
{
      object temp = sharePointListItem.FieldValues["UniqueId"];
      if (temp != null)
            itemGuid = (Guid)temp;
}


var initiationData = new Dictionary<string, object>();

//Start the Workflow
 ClientResult<Guid> resultGuid = workflowInteropService.StartWorkflow("MYWFD", new Guid(), sharePointList.Id, itemGuid, initiationData);

clientContext.ExecuteQuery();

由于某种原因,它向我抛出了这个异常,就好像我的 ItemGuid 不正确一样。

Microsoft.SharePoint.Client.ServerException was unhandled
  HResult=-2146233088
  Message=itemGuid
  Source=Microsoft.SharePoint.Client.Runtime
  ServerErrorCode=-2147024809
  ServerErrorTraceCorrelationId=80d8c19c-b093-1000-8fbc-c2919fdf4284
  ServerErrorTypeName=System.ArgumentException
  ServerStackTrace=""
  StackTrace:
       at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
       at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
       at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
       at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
       at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
       at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
       at SPCSOMTest.Program.StartListWorkflowAssociation(ClientContext clientContext) in c:\Program Files\nsoftware\SharePoint Integrator V4 .NET Edition\demos - winform\SPCSOMTest\SPCSOMTest\Program.cs:line 243
       at SPCSOMTest.Program.Main(String[] args) in c:\Program Files\nsoftware\SharePoint Integrator V4 .NET Edition\demos - winform\SPCSOMTest\SPCSOMTest\Program.cs:line 63
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

【问题讨论】:

    标签: sharepoint sharepoint-workflow csom


    【解决方案1】:

    我最近遇到了同样的问题。您使用了错误的 ID,而不是

    object temp = sharePointListItem.FieldValues["UniqueId"];
    

    你应该使用:

    object temp = sharePointListItem.FieldValues["GUID"];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多