通过调用REST API在列表项上启动工作流程 [英] Start workflow on a list item by calling REST API

查看:82
本文介绍了通过调用REST API在列表项上启动工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了一些文章,说我必须求助于

/_ api/SP.WorkflowServices.WorkflowInstanceService.Current/StartWorkflowOnListItemBySubscriptionId(subscriptionId ='e90bdef8-209b-436b-acd7-b6ec01abb578',itemId ='109')

但无法正常工作,响应是

{错误":{代码":-2147024809,System.ArgumentException",消息":{"lang":"ru-RU",值" :"subscription""}}}

然后我尝试了

/_ api/SP.WorkflowServices.InteropService.Current/StartWorkflow(associationName ='WorkflowName',listId ='79e70851-4ea2-45cf-8c6f-06adc9f3f226',itemGuid ='bfdffb1b-e7e4-4363-9f8f- 04641575724f')

但是问题还是相似的

{错误":{代码":-2147024809,System.ArgumentException",消息":{"lang":"ru-RU",值" :" associationName"}}}

我看到它说参数有问题,但是我看不到任何错误...

有人能做到吗?谢谢你的建议

解决方案

以下代码供您参考.修改"subscriptionId".和"itemId"在下面的代码中,然后将代码添加到Web部件页面的内容编辑器Web部件中.

<脚本src ="//code.jquery.com/jquery-3.1.0.min.js" type ="text/javascript"></script>
< script type =文本/javascript">
函数StartWorkflow(){


.ajax({ 网址:_spPageContextInfo.siteAbsoluteUrl +``/_api/SP.WorkflowServices.WorkflowInstanceService.Current/StartWorkflowOnListItemBySubscriptionId(subscriptionId='a158ae37-a4bb-4b80-9405-6db2aedc98af',itemId='2')',, 类型:"POST", contentType:"application/json; odata = verbose", 标头:{ "Accept":"application/json; odata = verbose", "X-RequestDigest":


("#__ REQUESTDIGEST").val() }, 成功:功能(数据){ alert('成功'); }, 错误:函数(数据){ alert(错误"); } }); } </script> <输入类型=按钮"; value ="StartWorkflow"; onclick =" StartWorkflow()"/>

最好的问候,

丹尼斯


I have read some articles that says that I have to resort to calling 

/_api/SP.WorkflowServices.WorkflowInstanceService.Current/StartWorkflowOnListItemBySubscriptionId(subscriptionId='e90bdef8-209b-436b-acd7-b6ec01abb578',itemId='109')

but can't make it work, the response is

{"error":{"code":"-2147024809, System.ArgumentException","message":{"lang":"ru-RU","value":"subscription"}}}

then I tried 

/_api/SP.WorkflowServices.InteropService.Current/StartWorkflow(associationName='WorkflowName',listId='79e70851-4ea2-45cf-8c6f-06adc9f3f226',itemGuid='bfdffb1b-e7e4-4363-9f8f-04641575724f')

but again the problem is similar 

{"error":{"code":"-2147024809, System.ArgumentException","message":{"lang":"ru-RU","value":"associationName"}}}

I see it says that the problem with parameters but I don't see any mistakes with them...

does anyone ever make it work? Thank for any advice

解决方案

Hi,

The following code for your reference. Modify the "subscriptionId" and "itemId" in the code below and then add the code into a content editor web part in the web part page.

<script src="//code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
function StartWorkflow(){


.ajax({ url: _spPageContextInfo.siteAbsoluteUrl + "/_api/SP.WorkflowServices.WorkflowInstanceService.Current/StartWorkflowOnListItemBySubscriptionId(subscriptionId='a158ae37-a4bb-4b80-9405-6db2aedc98af',itemId='2')", type: "POST", contentType: "application/json;odata=verbose", headers: { "Accept": "application/json;odata=verbose", "X-RequestDigest":


("#__REQUESTDIGEST").val() }, success: function (data) { alert('Success'); }, error: function (data) { alert("Error"); } }); } </script> <input type="button" value="StartWorkflow" onclick="StartWorkflow()"/>

Best Regards,

Dennis


这篇关于通过调用REST API在列表项上启动工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆