简体   繁体   English

无法使用CSOM启动List Sharepoint 2010 Platform工作流程

[英]Not able to start List Sharepoint 2010 Platform workflow using CSOM

I am using CSOM to Start a SharePoint 2010 Platform workflow associated to List. 我正在使用CSOM启动与列表关联的SharePoint 2010 Platform工作流。 Since this is SharePoint 2010 Workflow created in SharePoint 2013 Online, I am using workflow InteropService StartWorkflow method. 由于这是在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();

For some reason it is throwing me this exception as if my ItemGuid is not correct. 由于某种原因,它抛出了这个异常,好像我的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: 

I've got the same problem recently. 我最近也遇到了同样的问题。 You're using wrong ID, instead of 您使用的是错误的ID,而不是

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

you should use: 您应该使用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在SharePoint 2010中使用CSOM获取文件大小 - Get file size using CSOM in SharePoint 2010 CSOM Caml查询无法找到文件-SharePoint 2010 - CSOM Caml Query Not able to find file - SharePoint 2010 使用多重选择在SharePoint工作流SPD 2010中调用另一个列表 - Using a Multi Select to call another list in a SharePoint workflow SPD 2010 在SharePoint 2010中使用SP对象模型从列表中删除工作流 - Removing Workflow from the list using SP Object Model in SharePoint 2010 如何使用Sharepoint Designer 2010将批准工作流与自定义列表相关联 - how to associate an approval workflow to a custom list using sharepoint designer 2010 Sharepoint 2010:使用VS2012将工作流与列表动态关联 - Sharepoint 2010: Associate Workflow Dynamically with List using VS2012 SharePoint工作流2010平台可以工作,但SharePoint工作流2013平台不在SharePoint 2013中 - SharePoint workflow 2010 platform works, but SharePoint workflow 2013 platform does not in SharePoint 2013 从SharePoint 2010中列表项上的自定义按钮/操作启动工作流(全部使用Visual Studio 2010) - Start a workflow from a custom button/action on a list item in SharePoint 2010 (all with Visual Studio 2010) 从Web Services Sharepoint 2010开始工作流程 - Start workflow with web services Sharepoint 2010 Sharepoint 2010工作流程:添加具有列表内容的任务 - Sharepoint 2010 Workflow: add task with List content
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM