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

Can not Start SharePoint 2013 workflow from code

$
0
0

Hello Dear Friends,

I am facing a problem and need your help .

i want to start SharePoint 2013 workflow from SharePoint Server OM.

current user do not have permissions to start workflow.

so i want to start from an elevated web.

please help me how i can achieve.

here is the code what i have writen.

var workflowServiceManager = new WorkflowServicesManager(web);
                var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();
                //get all workflows associated with the list
                //get lsit
                SPList list = web.Lists["Leave"];
                if (list != null)
                {
                    var subscriptions = workflowSubscriptionService.EnumerateSubscriptionsByList(list.ID);
                    //run all workflows associated with the list
                    SPListItem item = list.GetItemById(Convert.ToInt32(drpRequest.SelectedValue));
                    foreach (var workflowSubscription in subscriptions)
                    {
                        //initiation parameters 
                        var inputParameters = new Dictionary<string, object>();
                        //inputParameters.Add("List", leaveList.ID);
                        workflowServiceManager.GetWorkflowInstanceService().StartWorkflowOnListItem(workflowSubscription, item.ID, inputParameters);
                    }

                }


Mukesh


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>