Not able to call JavaScript function on onClick Event

风流意气都作罢 提交于 2020-01-14 05:26:06

问题


**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 

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 function call**

HTML Button Code:

    <td class="ms-toolbar" nowrap="nowrap" align="right">

    <input type="button" runat="server" value="Assign To Next Step" name="AssignToNextStep" onClick="startWorkflow()"/>

   </td>

JavaScript Function Code is:

<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>

回答1:


That Function was out of Scope. I mean I just changed the place of that function.




回答2:


How do you insert the code? Have you checked the developer tools in your browser if it shows any errors?

Try to add

onClick="startWorkflow();return false;"

In your code.



来源:https://stackoverflow.com/questions/49109060/not-able-to-call-javascript-function-on-onclick-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!