tag:blogger.com,1999:blog-1804865242850018128.post2647136762501477288..comments2023-09-27T14:29:55.934+07:00Comments on Sohel's Blog: Programmatically Start SharePoint 2013 WorkflowAnonymoushttp://www.blogger.com/profile/15485221969375347012noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-1804865242850018128.post-8898482684587714462016-08-26T17:46:07.604+07:002016-08-26T17:46:07.604+07:00Hi Sohil,
Thank you very much for this informative...Hi Sohil,<br />Thank you very much for this informative article. I have created some SharePoint 2013 designer based Approval workflow. My approval workflow cancelled due to some issues like database drive get filled with logging database,STS unable to generate security token due to some reason. <br />Is there any way to restart the same workflow instance where it is cancelled. So that I don't loss the data till it was approved.<br />I am also trying to write some validation rules to suspend workflow if does not meeting prerequisite but unable to suspend it.I can terminate and cancel a workflow instance but unable to suspend it. Below is the code which I used to suspend a workflow but it did not suspend: <br /> web.AllowUnsafeUpdates = true;<br /> WorkflowServicesManager workflowServiceManager = new WorkflowServicesManager(web);<br /> var workflowSubscriptionService = workflowServiceManager.GetWorkflowSubscriptionService();<br /> <br /> var workflowInstanceService = workflowServiceManager.GetWorkflowInstanceService();<br /> var workflowInstances = workflowInstanceService.EnumerateInstancesForListItem(new Guid("2FC89C97-E1C4-48D6-BF9E-CC4EFAC4054A"), 4);<br /><br /> workflowInstanceService.SuspendWorkflow(workflowInstances[0]);<br /> web.Update();<br /> web.AllowUnsafeUpdates = false; <br /><br />Do have any idea please. <br />Thank you very much. Gireesh Painulyhttps://www.blogger.com/profile/02733586598356087397noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-5817871233739106262015-04-02T05:49:31.331+07:002015-04-02T05:49:31.331+07:00Note: You neeed to add the following references:
M...Note: You neeed to add the following references:<br />Microsoft.SharePoint: \Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.dll<br />Microsoft.SharePoint.WorkflowServicesBase: \Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.WorkflowServicesBase\v4.0_15.<br /><br />This is not mentioned, but is important to know.Sasquathttps://www.blogger.com/profile/08024058319558386392noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-56886016271654427102014-07-02T22:59:09.864+07:002014-07-02T22:59:09.864+07:00Note: The Dump()... is from LINQPad 4. they show:...Note: The Dump()... is from LINQPad 4. they show:<br /><br />WorkflowServicesManager: ServerObjectIsNull = False <br />WorkflowSubscriptionService: ServerObjectIsNull = True <br />Anonymoushttps://www.blogger.com/profile/06554654774876629718noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-44718601478272731202014-07-02T22:56:53.291+07:002014-07-02T22:56:53.291+07:00I can not get pass the WorkFlowSubscriptionService...I can not get pass the WorkFlowSubscriptionService ServerObjectIsNull == true:<br /><br /> public static void StartWorkflow(String Tier3TORSite, String userName)<br /> {<br /> ClientContext ctx = new ClientContext(Tier3TORSite) { Credentials = CredentialCache.DefaultCredentials }; <br /> Web web = ctx .Web;<br /> List documents = ctx.Web.Lists.GetByTitle("Time Off Requests"); <br /> ctx .Load(documents); <br /> ctx .ExecuteQuery(); <br /> WorkflowServicesManager wfManager = new WorkflowServicesManager(ctx, web); <br /> WorkflowInstanceService instanceService = wfManager.GetWorkflowInstanceService(); <br /> ListItemCollection items = documents.GetItems(CamlQuery.CreateAllItemsQuery()); <br /> ctx.Load(items); <br /> ctx.ExecuteQuery(); <br /> foreach (ListItem item in items) <br /> { <br /> var args1 = new Dictionary(); <br /> args1.Add("WorkflowHistory", "Hello"); <br /> <br /> // get reference to Workflow Service Manager (WSM) in SP... <br /> WorkflowServicesManager wsm = new WorkflowServicesManager(ctx, web); <br /> <br /> ctx.Load(wsm); <br /> ctx.ExecuteQuery(); <br /> wsm.ServerObjectIsNull.Dump("WorkflowServicesManager: ServerObjectIsNull");<br /> if (wsm.ServerObjectIsNull == true)<br /> {<br /> return;<br /> }<br /> else<br /> {<br /> // get reference to subscription service <br /> WorkflowSubscriptionService subscriptionService = wsm.GetWorkflowSubscriptionService(); <br /> ctx.Load(subscriptionService); <br /> ctx.ExecuteQuery(); <br /> subscriptionService.ServerObjectIsNull.Dump("WorkflowSubscriptionService: ServerObjectIsNull");<br /> if (subscriptionService.ServerObjectIsNull == true)<br /> {<br /> return;<br /> }<br /> else<br /> {<br /> var subscriptions = subscriptionService.EnumerateSubscriptionsByList(documents.Id); <br /> <br /> ctx.Load(subscriptions); <br /> ctx.ExecuteQuery(); <br /> instanceService.StartWorkflowOnListItem(subscriptions[0], item.Id, args1); <br /> ctx.ExecuteQuery(); <br /> } <br /> }<br /> } <br /> }Anonymoushttps://www.blogger.com/profile/06554654774876629718noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-90429789648954567142014-05-26T17:50:35.731+07:002014-05-26T17:50:35.731+07:00In a SharePoint online, I created an app that prov...In a SharePoint online, I created an app that provision a site and then initiate approval workflow. The problem I have is that, the app don't have enough permission to start the workflow. After the site is created, I have to set the permission by going to _layouts/15/appinv.aspx page the kick the workflow.<br /><br />the Workflows can use app permissions feature is already activated on the site.<br /><br />The question I have is, how can an app that created the site, start the workflow? <br />YThttps://www.blogger.com/profile/17952858896948920270noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-27904868938050751272014-03-03T19:31:36.593+07:002014-03-03T19:31:36.593+07:00sohel how to run sharepoint 2013 designer workflow...sohel how to run sharepoint 2013 designer workflow from application page programmatically . there are two workflow Getapproval & SendMail . i want to start these workflow from c# code.<br />Please help me me.Anonymoushttps://www.blogger.com/profile/09650455269394361588noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-53334958720033812022014-02-20T09:23:15.116+07:002014-02-20T09:23:15.116+07:00@SP Dev, not a good idea of showing initiation for...@SP Dev, not a good idea of showing initiation form from even receiver. If it's sync receiver then you can redirect the user to workflow initiation form. Otherwise you can initiate the workflow programmatically passing the initiation data.Anonymoushttps://www.blogger.com/profile/15485221969375347012noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-52197710367179752812014-02-20T05:22:44.942+07:002014-02-20T05:22:44.942+07:00How to load he initiation form, when called the wo...How to load he initiation form, when called the workflow instance programmatically through event receiver or something?SP DEVhttps://www.blogger.com/profile/08844873123859079101noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-1395910824474538422014-01-22T19:09:05.475+07:002014-01-22T19:09:05.475+07:00Thanks for the post but i always getting asp.net a...Thanks for the post but i always getting asp.net access denied when trying to start workflow...<br />i don't have problem to access & update list items.The web is running with custom user who has rights to SharePoint site and lists (owner)<br />thanksERhttps://www.blogger.com/profile/01248001477315869120noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-50394821093044723132013-10-29T22:33:30.219+07:002013-10-29T22:33:30.219+07:00We are not able to kick off workflow for read acce...We are not able to kick off workflow for read access users. We have to give contribute rights to those users. We tried token code but its not working.<br />Do you know any fixAmit Lohogaonkar Sharepointerhttps://www.blogger.com/profile/13571670068586762663noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-39337693234521590392013-09-16T10:02:13.559+07:002013-09-16T10:02:13.559+07:00@mayflower, you need to retrieve the workflow defi...@mayflower, you need to retrieve the workflow definition by using 'WorkflowServiceManager.GetWorkflowDeploymentService().GetDefinition(workflowSubscription.DefinitionId)'. Then in the workflow definition you will find the properties as well as initiation/association form url.Anonymoushttps://www.blogger.com/profile/15485221969375347012noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-59926299783866391352013-09-13T03:30:24.422+07:002013-09-13T03:30:24.422+07:00Hi Sohel, thanks for sharing your knowledge in SP2...Hi Sohel, thanks for sharing your knowledge in SP2013 workflows which are very helpful to me. I am using a solution similar to yours to start a workflow on a list item. The problem I encountered is that I want to redirect the user to the Initiation Form page if the Initiation Form Parameters have been defined for the workflow, and skip this step (just start the workflow) if no parameters have been defined. However I cannot find a property in the new API that can help me determine if the parameters have been defined or not. For SP2010 workflows, I can check the InstantiationUrl property of the SPWorkflowAssociation object to determine this, but I have not found a similar way to achieve this for SP2013 workflows. <br /><br />Any suggestion is greatly appreciated!<br /><br />Thanks.mayflowerhttps://www.blogger.com/profile/09528421493938814079noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-15243366670370755482013-08-09T08:30:35.015+07:002013-08-09T08:30:35.015+07:00@Vladimir, You need to create Argument with direct...@Vladimir, You need to create Argument with direction 'In'. Please take a look at the example: http://code.msdn.microsoft.com/office/SharePoint-2013-Approval-f5ac5eb2/Anonymoushttps://www.blogger.com/profile/15485221969375347012noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-76010817762180134942013-08-08T18:58:48.932+07:002013-08-08T18:58:48.932+07:00Hi Sohel!
How to work with "inputParameters&q...Hi Sohel!<br />How to work with "inputParameters" dictionary values inside workflow? I mean how to get these values into workflow variables in Visual Studio? <br />I tried to create Argument with the same name as key name. Got an error at workflow feature activating. And I tried to use ExternalVariableValue activity - also got an error.<br />Please help with my question.<br />Thanks.Anonymoushttps://www.blogger.com/profile/17241911001644789457noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-25491575814704754122013-06-13T08:20:48.965+07:002013-06-13T08:20:48.965+07:00As far as I know, you can access workflow variable...As far as I know, you can access workflow variables only inside workflow. However you can pass your variable to external WCF service. So if you need to access workflow variables in C# code then pass the variables in the service as the new WF model doesn't allow any C# code in normal scenario.Anonymoushttps://www.blogger.com/profile/15485221969375347012noreply@blogger.comtag:blogger.com,1999:blog-1804865242850018128.post-75251382783131070462013-06-12T22:57:08.612+07:002013-06-12T22:57:08.612+07:00Hello Sohel.
Thank you very much for sharing the ...Hello Sohel. <br />Thank you very much for sharing the information related to SP2013 workflows and Workflow Manager. As I can see you are one of not so many people who try to make their own investigation and share knowledge of the new WF platform to help others to overcome the lack of documentation. Thank you for that!<br /><br />I am trying to understand how to work with this technology in deep and have a question that you probably know the answer for. Do you know whether it is possible to get value of SPD WF variable from C# code? I tried to do that with Microsoft.Workflow.Client and Microsoft.SharePoint.Client.WorkflowServices namespaces, but with no result. Do you have any ideas?Anonymoushttps://www.blogger.com/profile/01282219131228087206noreply@blogger.com