{
  "metadata": {
    "flowMigrator": {
      "sourceContractVersion": 5,
      "excludedSourceActionIds": [],
      "valueSchemas": {},
      "runtimeInputs": [],
      "componentSource": false
    },
    "workflowEntityId": null,
    "processAdvisorMetadata": null,
    "flowChargedByPaygo": null,
    "provisioningMethod": "FromDefinition",
    "failureAlertSubscription": true,
    "creationSource": null
  },
  "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "$connections": {
      "defaultValue": {},
      "type": "Object"
    },
    "$authentication": {
      "defaultValue": {},
      "type": "SecureObject"
    }
  },
  "triggers": {
    "manual": {
      "type": "Request",
      "kind": "Button",
      "inputs": {
        "schema": {
          "type": "object",
          "properties": {},
          "required": []
        }
      },
      "metadata": {
        "operationMetadataId": "10c3e4cb-11c3-e65e-12c3-e7f113c3e984"
      }
    }
  },
  "actions": {
    "001_Review_evaluation_request": {
      "type": "Scope",
      "description": "Nintex task/approval with migrated outcome branches.",
      "actions": {
        "Start_and_wait_for_approval": {
          "runAfter": {},
          "metadata": {
            "operationMetadataId": "0cb02ca6-efe8-4d28-a5f6-32dd2435d955"
          },
          "type": "OpenApiConnectionWebhook",
          "inputs": {
            "host": {
              "apiId": "/providers/Microsoft.PowerApps/apis/shared_approvals",
              "connectionName": "shared_approvals",
              "operationId": "StartAndWaitForAnApproval"
            },
            "parameters": {
              "approvalType": "Basic",
              "WebhookApprovalCreationInput/title": "Review synthetic evaluation request",
              "WebhookApprovalCreationInput/assignedTo": "reviewer@example.invalid",
              "WebhookApprovalCreationInput/enableNotifications": true,
              "WebhookApprovalCreationInput/enableReassignment": true,
              "WebhookApprovalCreationInput/details": "Approve or reject this synthetic request in a test environment.<br/><br/>Nintex outcomes: [\"Approve\",\"Reject\"]",
              "WebhookApprovalCreationInput/itemLink": "@{coalesce(triggerBody()?['ItemUrl'], triggerBody()?['Link'], triggerBody()?['{Link}'], triggerBody()?['Link to item'], '')}",
              "WebhookApprovalCreationInput/itemLinkDescription": "Open source SharePoint item"
            }
          }
        },
        "Branch_on_approval_outcome": {
          "type": "If",
          "expression": "@or(contains(toLower(coalesce(outputs('Start_and_wait_for_approval')?['body/outcome'], body('Start_and_wait_for_approval')?['outcome'], '')), 'approve'), contains(toLower(coalesce(outputs('Start_and_wait_for_approval')?['body/outcome'], body('Start_and_wait_for_approval')?['outcome'], '')), 'approved'), contains(toLower(coalesce(outputs('Start_and_wait_for_approval')?['body/outcome'], body('Start_and_wait_for_approval')?['outcome'], '')), 'accept'), contains(toLower(coalesce(outputs('Start_and_wait_for_approval')?['body/outcome'], body('Start_and_wait_for_approval')?['outcome'], '')), 'accepted'), contains(toLower(coalesce(outputs('Start_and_wait_for_approval')?['body/outcome'], body('Start_and_wait_for_approval')?['outcome'], '')), 'yes'))",
          "actions": {
            "002_Record_approved_request": {
              "runAfter": {},
              "metadata": {
                "operationMetadataId": "912da7ce-e4d9-4648-8006-65d152bf9392",
                "flowMigrator": {
                  "explicitSharePointFields": [
                    "Title"
                  ],
                  "sourceActionId": "create-audit",
                  "normalizedType": "sharepoint.item.create",
                  "representedSourceActionIds": [
                    "approved-path"
                  ]
                }
              },
              "type": "OpenApiConnection",
              "inputs": {
                "host": {
                  "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline",
                  "connectionName": "shared_sharepointonline",
                  "operationId": "PostItem"
                },
                "parameters": {
                  "dataset": "https://example.invalid/sites/evaluation",
                  "table": "EvaluationAudit",
                  "item/Title": "Synthetic approved request"
                },
                "authentication": {
                  "value": "@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']",
                  "type": "Raw"
                }
              }
            },
            "003_Two_review_checkpoints": {
              "type": "Scope",
              "actions": {
                "Source_repeat_count": {
                  "type": "Compose",
                  "inputs": 2,
                  "metadata": {
                    "flowMigrator": {
                      "operationRole": "Source_repeat_count"
                    },
                    "operationMetadataId": "b2e7bd0e-b1e7-bb7b-b0e7-b9e8b7e7c4ed"
                  },
                  "runAfter": {}
                },
                "Validate_repeat_count": {
                  "type": "ParseJson",
                  "runAfter": {
                    "Source_repeat_count": [
                      "Succeeded"
                    ]
                  },
                  "inputs": {
                    "content": "@outputs('Source_repeat_count')",
                    "schema": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 1000
                    }
                  },
                  "metadata": {
                    "flowMigrator": {
                      "operationRole": "Validate_repeat_count"
                    },
                    "operationMetadataId": "306f7bc7-316f-7d5a-326f-7eed2b6f73e8"
                  }
                },
                "Repeat_source_count": {
                  "type": "Foreach",
                  "runAfter": {
                    "Validate_repeat_count": [
                      "Succeeded"
                    ]
                  },
                  "foreach": "@range(0, body('Validate_repeat_count'))",
                  "runtimeConfiguration": {
                    "concurrency": {
                      "repetitions": 1
                    }
                  },
                  "actions": {
                    "004_Record_checkpoint": {
                      "type": "Compose",
                      "description": "Nintex Log to instance details migrated as a Compose review/audit step. Validate whether this should also write to a SharePoint audit list or Dataverse table.",
                      "inputs": "Approved path checkpoint",
                      "metadata": {
                        "flowMigrator": {
                          "sourceActionId": "loop-note",
                          "normalizedType": "workflow.log"
                        },
                        "operationMetadataId": "0c182a92-0b18-28ff-0a18-276c091825d9"
                      },
                      "runAfter": {}
                    }
                  },
                  "metadata": {
                    "flowMigrator": {
                      "operationRole": "Repeat_source_count"
                    },
                    "operationMetadataId": "3079f862-2f79-f6cf-2e79-f53c2d79f3a9"
                  }
                }
              },
              "metadata": {
                "flowMigrator": {
                  "operationContract": "source-loop.v1",
                  "operationSource": {
                    "id": "review-loop",
                    "normalizedType": "workflow.loop",
                    "className": "engine:loopv2",
                    "config": {
                      "xtInputs": {
                        "RepeatCount": {
                          "literal": "2"
                        }
                      },
                      "xtOutputs": {}
                    }
                  },
                  "sourceActionId": "review-loop",
                  "normalizedType": "workflow.loop"
                },
                "operationMetadataId": "6794f7d4-6a94-fc8d-6994-fafa6494f31b"
              },
              "runAfter": {
                "002_Record_approved_request": [
                  "Succeeded"
                ]
              }
            }
          },
          "else": {
            "actions": {
              "005_Record_rejection": {
                "type": "Compose",
                "description": "Nintex Log to instance details migrated as a Compose review/audit step. Validate whether this should also write to a SharePoint audit list or Dataverse table.",
                "inputs": "Rejected request — no audit item created",
                "metadata": {
                  "flowMigrator": {
                    "sourceActionId": "rejected-note",
                    "normalizedType": "workflow.log",
                    "representedSourceActionIds": [
                      "rejected-path"
                    ]
                  },
                  "operationMetadataId": "4bdfc02e-4adf-be9b-49df-bd0850dfc80d"
                },
                "runAfter": {}
              }
            }
          },
          "runAfter": {
            "Start_and_wait_for_approval": [
              "Succeeded"
            ]
          },
          "metadata": {
            "operationMetadataId": "708fb282-6f8f-b0ef-6e8f-af5c6d8fadc9"
          }
        }
      },
      "metadata": {
        "flowMigrator": {
          "sourceActionId": "request-approval",
          "normalizedType": "workflow.task.assign"
        },
        "operationMetadataId": "50c13020-53c1-34d9-52c1-334655c137ff"
      },
      "runAfter": {}
    }
  }
}