{
  "Id": "17244e92-ca05-45c4-9603-174520146a5e",
  "DisplayName": "Copy Approval Comment to Metadata Field on Enrollment",
  "Description": "Copy Approval Comment to Metadata Field on Enrollment",
  "Key": "507",
  "KeyDisplayName": "Enterprise Web Server",
  "IsPublished": true,
  "WorkflowType": "Enrollment",
  "Steps": [
    {
      "Id": "fafdb96d-b035-49c9-a78a-389dcbc3da86",
      "DisplayName": "End-NOOP",
      "UniqueName": "EndNOOP",
      "ExtensionName": "NOOPStep",
      "Enabled": true,
      "ConfigurationParameters": {},
      "Signals": [],
      "Conditions": [],
      "Outputs": {}
    },
    {
      "Id": "51a77508-0878-447e-a2ce-417fa2415997",
      "DisplayName": "Keyfactor-Enroll",
      "UniqueName": "KeyfactorEnroll",
      "ExtensionName": "EnrollStep",
      "Enabled": true,
      "ConfigurationParameters": {},
      "Signals": [],
      "Conditions": [],
      "Outputs": {
        "continue": "EndNOOP"
      }
    },
    {
      "Id": "dffaa006-9b31-403e-8a47-483c5062926a",
      "DisplayName": "Require Approval",
      "UniqueName": "RequireApproval1",
      "ExtensionName": "RequireApproval",
      "Enabled": true,
      "ConfigurationParameters": {
        "MinimumApprovals": "1",
        "DenialEmailSubject": "Request Denied for $(request:cn)",
        "DenialEmailMessage": "Hello $(requester:givenname),\n\nThe certificate you requested on $(subdate) in the name $(request:cn) has not been issued for the following reason:\n\n$(approvalsignalcmnts)\n\nThe certificate details include:\n\n   <ul>\n      <li>CN: $(request:cn)</li>\n      <li>DN: $(request:dn)</li>\n      <li>SANs: $(sans))</li>\n      <li>App Owner First Name: $(metadata:AppOwnerFirstName)</li>\n      <li>App Owner Last Name: $(metadata:AppOwnerLastName)</li>\n   </ul>\n\nFor assistance, please contact <a href=\\\"mailto:support@keyexample.com\\\">support@keyexample.com</a>.\n\nThanks!\n\nYour Certificate Management System",
        "DenialEmailRecipients": [
          "pkiadmins@keyexample.com"
        ],
        "ApprovalEmailSubject": "Certificate Enrollment Request Approved for $(request:cn)",
        "ApprovalEmailMessage": "Hello $(requester:givenname),\n\nThe certificate you requested in the name $(request:cn) on $(subdate) was successfully approved with the following comment:\n\n$(approvalsignalcmnts)\n\nThe certificate details include:\n\n   <ul>\n      <li>CN: $(request:cn)</li>\n      <li>DN: $(request:dn)</li>\n      <li>SANs: $(sans))</li>\n      <li>App Owner First Name: $(metadata:AppOwnerFirstName)</li>\n      <li>App Owner Last Name: $(metadata:AppOwnerLastName)</li>\n   </ul>\n\nYou will receive an update when it has been issued. For assistance, please contact <a href=\\\"mailto:support@keyexample.com\\\">support@keyexample.com</a>.\n\nThanks!\n\nYour Certificate Management System",
        "ApprovalEmailRecipients": [
          "pkiadmins@keyexample.com"
        ],
        "RequesterCanApprove": true
      },
      "Signals": [
        {
          "RoleIds": [],
          "SignalName": "ApprovalStatus"
        }
      ],
      "Conditions": [],
      "Outputs": {
        "continue": "PowerShell1"
      }
    },
    {
      "Id": "d4bfbaeb-122f-4c14-9023-923a103072ec",
      "DisplayName": "Retain Approval Comment",
      "UniqueName": "PowerShell1",
      "ExtensionName": "PowerShell",
      "Enabled": true,
      "ConfigurationParameters": {
        "ScriptParameters": {
          "ApprovalComment": "$(metadata:ApprovalComments)",
          "SignalComment": "$(approvalsignalcmnts)",
          "Metadata": "$(Metadata)"
        },
        "ScriptContent": "# Declare your parameters at the beginning\r\nparam(\r\n   [string]$ApprovalComment,\r\n   [string]$SignalComment,\r\n   [string]$Metadata\r\n)\r\n\r\n# Initialize a hashtable to contain your metadata fields and populate it\r\n$UpdatedMetadata = @{}\r\n\r\n$metaObject = $Metadata | ConvertFrom-Json -AsHashtable\r\n\r\nforeach ($property in $metaObject.Keys) {\r\n    $UpdatedMetadata[$property] = $metaObject[$property]\r\n}\r\n\r\n# Append your signal comment(s) to any existing comment in the ApprovalComments metadata field\r\nif([string]::IsNullOrWhiteSpace($ApprovalComment)) {\r\n   $UpdatedMetadata['ApprovalComments'] = $SignalComment\r\n}else {\r\n   $UpdatedMetadata['ApprovalComments'] = $ApprovalComment + \", \" + $SignalComment\r\n}\r\n\r\n# Return the updated metadata fields, including ApprovalComments, to the workflow in the original parameter as a hashtable\r\n$result = @{ \"Metadata\" = $UpdatedMetadata }\r\nreturn $result"
      },
      "Signals": [],
      "Conditions": [],
      "Outputs": {
        "continue": "KeyfactorEnroll"
      }
    },
    {
      "Id": "a349765d-f956-4d5f-b093-ec72a61ab621",
      "DisplayName": "Start-NOOP",
      "UniqueName": "StartNOOP",
      "ExtensionName": "NOOPStep",
      "Enabled": true,
      "ConfigurationParameters": {},
      "Signals": [],
      "Conditions": [],
      "Outputs": {
        "continue": "RequireApproval1"
      }
    }
  ],
  "DraftVersion": 1,
  "PublishedVersion": 1,
  "Enabled": true
}