Sharepoint 无法在onClick事件上调用JavaScript函数
我已为SharePoint online自定义列表创建了自定义编辑表单。在这里,我创建了一个自定义按钮,通过它我将启动一个工作流。 问题是我无法在单击按钮时调用该函数。我在函数调用中也使用了一个逗号** HTML按钮代码:Sharepoint 无法在onClick事件上调用JavaScript函数,sharepoint,sharepoint-2013,sharepoint-online,sharepoint-designer,Sharepoint,Sharepoint 2013,Sharepoint Online,Sharepoint Designer,我已为SharePoint online自定义列表创建了自定义编辑表单。在这里,我创建了一个自定义按钮,通过它我将启动一个工作流。 问题是我无法在单击按钮时调用该函数。我在函数调用中也使用了一个逗号** HTML按钮代码: **I have created a custom edit form for a SharePoint online custom list. Where I have created a custom button via which I will start a Wor
**I have created a custom edit form for a SharePoint online custom list. Where I have created a custom button via which I will start a Workflow.
the issue is I am not able to call that function on button click. I have used a single comma also for the function call
JavaScript函数代码为:
<td class="ms-toolbar" nowrap="nowrap" align="right">
<input type="button" runat="server" value="Assign To Next Step" name="AssignToNextStep" onClick="startWorkflow()"/>
</td>
函数startWorkflow()
{
警惕(“内部”);
尝试
{
showInProgressDialog();
var ctx=SP.ClientContext.get_current();
var wfManager=SP.WorkflowServices.WorkflowServicesManager.newObject(ctx,ctx.get_web());
var subscription=wfManager.getWorkflowSubscriptionService().getSubscription(“我的工作流ID”);
加载(订阅“PropertyDefinitions”);
ctx.executeQueryAsync(
函数(发送方,参数)
{
wfManager.getWorkflowInstanceService().startWorkflow(订阅“”);
ctx.executeQueryAsync(
函数(发送方,参数)
{
closeInProgressDialog();
},
函数(发送方,参数)
{
closeInProgressDialog();
警报(错误消息);
});
});
}
捕获(ex)
{
警报(ex);
dlg.close();
}
}
如何插入代码?如果浏览器中显示任何错误,您是否已检查开发人员工具
尝试添加
<script type="text/javascript">
function startWorkflow()
{
alert("Inside");
try
{
showInProgressDialog();
var ctx = SP.ClientContext.get_current();
var wfManager = SP.WorkflowServices.WorkflowServicesManager.newObject(ctx, ctx.get_web());
var subscription = wfManager.getWorkflowSubscriptionService().getSubscription("My Workflow ID");
ctx.load(subscription, 'PropertyDefinitions');
ctx.executeQueryAsync(
function(sender, args)
{
wfManager.getWorkflowInstanceService().startWorkflow(subscription, "");
ctx.executeQueryAsync(
function(sender, args)
{
closeInProgressDialog();
},
function (sender, args)
{
closeInProgressDialog();
alert(errorMessage);
});
});
}
catch(ex)
{
alert(ex);
dlg.close();
}
}
</script>
在代码中。该函数超出范围。我的意思是我刚刚更改了该函数的位置。你是说你的startWorkflow()函数没有被调用吗?因为我刚刚在一个代码笔中尝试了它,它被调用了,我也得到了你在开始时设置的警报。这是链接是的,我检查过它在codepen上运行得很好,但在Sharepoint中没有。澄清问题最好在问题的评论中发布,而不是在回答中。
onClick="startWorkflow();return false;"