Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

cancelWorkflow in SharePoint hosted app

$
0
0

Hi,

I am developing a SharePoint hosted app for office 365 site.I have a list in the app web on which a workflow is running on item added event.On click of a Cancel link in the list item, I am trying to cancel the workflow using following code

   // connect to the instance service
     var workflowInstanceService = workflowServicesManager.getWorkflowInstanceService();
     var workflowInstances = workflowInstanceService.enumerateInstancesForListItem(ListId, itemID)

      context.load(workflowInstances);
      context.executeQueryAsync(function (sender, args) {
                var instancesEnum = workflowInstances.getEnumerator();
                while (instancesEnum.moveNext()) {
                       var instance = instancesEnum.get_current();
       workflowInstanceService.cancelWorkflow(instance);
                       context.executeQueryAsync(function (sender, args) {},errfunc);

Everything works fine when I login to the app, as site collection administrator and cancel the workflow.With any other user I get Permission denied, UnAuthorizedAccess exception on cancelWorkflow method.Please guide how can I achieve this.

If I need to call a webservice from javascript, please help me understand the steps to host the webservice for it to be accessible from sharepoint online.Thanks!

regards,

Sharepoint lead


Viewing all articles
Browse latest Browse all 7589

Trending Articles