Skip to main content

12 - Create the 'ServiceNow Close Incident' tool

In this module we will create a stateful workflow to close an existing ServiceNow incident and add resolution comments.

Create the Stateful Workflow

  1. Search for and navigate to the Logic Apps service

    Search and Navigate to the Logic Apps Service

  2. Open the Logic App created earlier

    Open Logic App

  3. Create a new workflow

    • Click Workflows -> Workflows from the menu on the left

    • Click + Add -> Add

      Create New Workflow

  4. Create a new stateful workflow with:

    • Workflow name: tool-ServiceNow-CloseIncident
    • Select the radio button for the Stateful workflow type
    • Click Create

    Create Stateful Workflow

  5. Open the workflow visual editor by clicking on the tool-ServiceNow-UpdateIncident link (if the workflow designer isn't opened automatically)

    Open Workflow

Configure Workflow

  1. Configure the workflow trigger to accept an HTTP Request

    • Click on Add Trigger

    • Select the Request action located in the Built-in tools group

      Add Trigger - Request Action

    • Select the When a HTTP request is received

      Select Action When a HTTP Request is Recieved

  2. Configure the When a HTTP request is received action:

    • Request Body JSON Schema
      {
      "type": "object",
      "properties": {
      "TicketNumber": {
      "type": "string"
      },
      "Notes": {
      "type": "string"
      }
      }
      }
  3. Look up the internal identifier for the Incident in ServiceNow

    • Add a new action. Click + Add an action

      Add an action

    • Select the ServiceNow - List Records action

      Select Action ServiceNow List Records

  4. Configure the List Records Activity as follows

    • Rename activity to List Records - Get Ticket Details

    • Record Type: Incident

    • Advanced Parameters (click Show all)

    • Query: number=@{triggerBody()?['TicketNumber']}

      (note: notice that the connection for the ServiceNow connection was automatically selected for the activity)

      ServiceNow List Activity Configuration

  5. Add the Update Record action to update the work notes on the incident in ServiceNow

    • Click on the + -> Add an Action

    • Search for ServiceNow Connector and select the Update Record Activity

      ServiceNow Update Activity

  6. Configure the Update Record action

    • Rename activity to Update Incident Work Notes

    • Record Type: Incident

    • System ID: (using the expression (fx) editor) first(body('List_Records_-_Get_Ticket_Details')?['result'])['sys_id']

    • State: (Advanced Parameter) 7

    • Resolution Code: (Advanced Parameter) Solution Provided

    • Resolution Notes: (Advanced Parameter) @{triggerBody()?['Notes']}

      ServiceNow Update Activity Config

  7. Add the Response activity to return a status message to the calling process

    • Click on the + -> Add an Action
    • Search for and select the Response activity

    Search Activity Response

  8. Configure the Response activity

    • Body:
      {
      "status": "Ticket {@{triggerBody()?['TicketNumber']}} has been updated successfully"
      }

    Response Activity Config

  9. Save your workflow

    Save Workflow