Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit ba7615b

Browse files
James MayJames May
authored andcommitted
Start-WorkflowInstance: return GUID of created WorkflowInstance
1 parent 172d641 commit ba7615b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Commands/Workflows/StartWorkflowInstance.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
using System.Management.Automation;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Management.Automation;
4+
25
using Microsoft.SharePoint.Client;
6+
using Microsoft.SharePoint.Client.WorkflowServices;
7+
38
using PnP.PowerShell.CmdletHelpAttributes;
49
using PnP.PowerShell.Commands.Base.PipeBinds;
5-
using Microsoft.SharePoint.Client.WorkflowServices;
6-
using System.Collections.Generic;
710

811
namespace PnP.PowerShell.Commands.Workflows
912
{
1013
[Cmdlet(VerbsLifecycle.Start, "PnPWorkflowInstance")]
1114
[CmdletHelp("Starts a SharePoint 2010/2013 workflow instance on a list item",
1215
DetailedDescription = "Allows starting a SharePoint 2010/2013 workflow on a list item in a list",
16+
OutputType = typeof(Guid),
17+
OutputTypeDescription = "Returns the GUID of the new workflow instance",
1318
Category = CmdletHelpCategory.Workflows,
1419
SupportedPlatform = CmdletSupportedPlatform.All)]
1520
[CmdletExample(
@@ -56,11 +61,16 @@ protected override void ExecuteCmdlet()
5661

5762
var inputParameters = new Dictionary<string, object>();
5863

64+
65+
5966
WorkflowServicesManager workflowServicesManager = new WorkflowServicesManager(ClientContext, SelectedWeb);
6067
WorkflowInstanceService instanceService = workflowServicesManager.GetWorkflowInstanceService();
6168

62-
instanceService.StartWorkflowOnListItem(subscription, ListItemID, inputParameters);
69+
var instanceResult = instanceService.StartWorkflowOnListItem(subscription, ListItemID, inputParameters);
70+
6371
ClientContext.ExecuteQueryRetry();
72+
73+
WriteObject(instanceResult.Value);
6474
}
6575
}
6676
}

0 commit comments

Comments
 (0)