Skip to content

Commit f2c4c10

Browse files
2 parents 51be66b + 4c7e63f commit f2c4c10

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

launcher-csharp/Maestro/Controllers/Mae004CancelWorkflowInstanceController.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace DocuSign.CodeExamples.Controllers
1616
public class Mae004CancelWorkflowInstanceController : EgController
1717
{
1818
private const int StatusCode = 500;
19+
private const string InProgress = "In Progress";
1920

2021
public Mae004CancelWorkflowInstanceController(DsConfiguration dsConfig,
2122
LauncherTexts launcherTexts,
@@ -69,6 +70,20 @@ public IActionResult Create()
6970

7071
try
7172
{
73+
var workflowInstance = CancelWorkflowInstance.GetWorkflowInstanceStatus(
74+
basePath,
75+
accessToken,
76+
accountId,
77+
workflowId,
78+
workflowInstanceId).Result;
79+
80+
if (workflowInstance.WorkflowStatus != null && !workflowInstance.WorkflowStatus.Equals(InProgress))
81+
{
82+
this.ViewBag.h1 = this.CodeExampleText.ExampleName;
83+
this.ViewBag.message = this.CodeExampleText.CustomErrorTexts[2].ErrorMessage;
84+
return this.View("example_done");
85+
}
86+
7287
var cancelWorkflowInstanceResponse = CancelWorkflowInstance.CancelInstanceMaestroWorkflow(
7388
basePath,
7489
accessToken,

launcher-csharp/Maestro/Examples/CancelWorkflowInstance.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ public static async Task<CancelWorkflowInstanceResponse> CancelInstanceMaestroWo
2424

2525
//ds-snippet-end:Maestro4Step3
2626

27+
public static async Task<WorkflowInstance> GetWorkflowInstanceStatus(
28+
string basePath,
29+
string accessToken,
30+
string accountId,
31+
string workflowId,
32+
string workflowInstanceId)
33+
{
34+
var client = CreateAuthenticatedClient(basePath, accessToken);
35+
return await client.Maestro.WorkflowInstanceManagement.GetWorkflowInstanceAsync(accountId, workflowId, workflowInstanceId);
36+
}
37+
2738
/// <summary>
2839
/// Creates an authenticated IAM client.
2940
/// </summary>

manifest/CodeExamplesManifest.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2911,8 +2911,8 @@
29112911
"Examples": [
29122912
{
29132913
"ExampleNumber": 1,
2914-
"ExampleName": "How to trigger a Maestro workflow",
2915-
"ExampleDescription": "Trigger a workflow",
2914+
"ExampleName": "Trigger a Maestro workflow",
2915+
"ExampleDescription": "This example demonstrates how to trigger a Maestro workflow",
29162916
"LinksToAPIMethod": [
29172917
{
29182918
"Path": "https://developers.docusign.com/docs/maestro-api/reference/maestro/workflows/triggerworkflow/",
@@ -2964,7 +2964,7 @@
29642964
{
29652965
"ExampleNumber": 2,
29662966
"ExampleName": "Pause a running workflow instance",
2967-
"ExampleDescription": "how to create an envelope where the workflow is paused before the envelope is sent to a second recipient",
2967+
"ExampleDescription": "This example demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient",
29682968
"LinksToAPIMethod": [
29692969
{
29702970
"Path": "https://developers.docusign.com/docs/maestro-api/reference/maestro/workflows/pausenewworkflowinstances/",
@@ -3025,6 +3025,10 @@
30253025
{
30263026
"ErrorMessageCheck": "NO_WORKFLOW_ID_FOUND",
30273027
"ErrorMessage": "Unable to retrieve workflow instance: {0}."
3028+
},
3029+
{
3030+
"ErrorMessageCheck": "NO_WORKFLOW_INSTANCE_COMPLETED",
3031+
"ErrorMessage": "The workflow instance has been completed and can no longer be canceled. Please trigger the workflow instance again, but stop before completing the signing process, then try running it once more."
30283032
}
30293033
],
30303034
"ResultsPageText": "Workflow has been canceled.",

0 commit comments

Comments
 (0)