Skip to main content

Check out Port for yourselfย 

Trigger ServiceNow Incident

Overviewโ€‹

This guide will help you implement a self-service action in Port that allows you to trigger incidents in ServiceNow directly from Port. This functionality streamlines incident management by enabling users to quickly create ServiceNow incidents without leaving Port.

You can implement this action in two ways:

  1. GitHub workflow: A more flexible approach that allows for complex workflows and custom logic, suitable for teams that want to maintain their automation in Git.
  2. Synced webhooks: A simpler approach that directly interacts with ServiceNow's API through Port, ideal for quick implementation and minimal setup.

Prerequisitesโ€‹

  • Complete the onboarding process.

  • Access to your ServiceNow instance with permissions to create incidents.

  • ServiceNow instance URL, username and password. Head over to ServiceNow to get your credentials.

  • Optional - Install Port's ServiceNow integration learn more.

    ServiceNow integration

    This step is not required for this example, but it will create all the blueprint boilerplate for you, and also update the catalog in real time with the new incident created.

Set up data modelโ€‹

If you haven't installed the ServiceNow integration, you'll need to create a blueprint for ServiceNow incidents in Port. However, we highly recommend you install the ServiceNow integration to have these automatically set up for you.

Create the ServiceNow incident blueprint

ServiceNow Incident Blueprint (Click to expand)
{
"identifier": "servicenowIncident",
"title": "Servicenow Incident",
"icon": "Service",
"schema": {
"properties": {
"category": {
"title": "Category",
"type": "string"
},
"reopenCount": {
"title": "Reopen Count",
"type": "string"
},
"severity": {
"title": "Severity",
"type": "string"
},
"assignedTo": {
"title": "Assigned To",
"type": "string",
"format": "url"
},
"urgency": {
"title": "Urgency",
"type": "string"
},
"contactType": {
"title": "Contact Type",
"type": "string"
},
"createdOn": {
"title": "Created On",
"type": "string",
"format": "date-time"
},
"createdBy": {
"title": "Created By",
"type": "string"
},
"isActive": {
"title": "Is Active",
"type": "boolean"
},
"priority": {
"title": "Priority",
"type": "string"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {}
}

Implementationโ€‹

You can trigger ServiceNow incidents by leveraging Port's synced webhooks and secrets to directly interact with the ServiceNow API. This method simplifies the setup by handling everything within Port.

Add Port secrets

Existing secrets

If you have already installed Port's ServiceNow integration, these secrets should already exist in your portal.
To view your existing secrets:

  1. Click on the ... button in the top right corner of your Port application.
  2. Choose Credentials, then click on the Secrets tab.

To add these secrets to your portal:

  1. Click on the ... button in the top right corner of your Port application.

  2. Click on Credentials.

  3. Click on the Secrets tab.

  4. Click on + Secret and add the following secrets:

    • SERVICENOW_INSTANCE_URL - Your ServiceNow instance URL.
    • SERVICENOW_USERNAME - Your ServiceNow instance username.
    • SERVICENOW_PASSWORD - Your ServiceNow instance password.

Set up self-service action

Follow these steps to create the self-service action:

  1. Head to the self-service page.

  2. Click on the + New Action button.

  3. Click on the {...} Edit JSON button.

  4. Copy and paste the following JSON configuration into the editor.

    Trigger ServiceNow Incident (Webhook) (Click to expand)
    {
    "identifier": "servicenowIncident_trigger_incident_webhook",
    "title": "Trigger ServiceNow Incident (Webhook)",
    "icon": "Service",
    "description": "Trigger a new incident in ServiceNow using webhook",
    "trigger": {
    "type": "self-service",
    "operation": "CREATE",
    "userInputs": {
    "properties": {
    "short_description": {
    "icon": "DefaultProperty",
    "title": "Short Description",
    "description": "Description of the incident",
    "type": "string"
    },
    "assigned_to": {
    "icon": "DefaultProperty",
    "title": "Assigned To",
    "description": "User this incident is assigned to",
    "type": "string"
    },
    "urgency": {
    "title": "Urgency",
    "icon": "DefaultProperty",
    "type": "string",
    "default": "2",
    "enum": [
    "1",
    "2",
    "3"
    ],
    "enumColors": {
    "1": "red",
    "2": "yellow",
    "3": "green"
    }
    },
    "sysparm_display_value": {
    "title": "Sysparm Display Value",
    "description": "Determines the type of data returned",
    "icon": "DefaultProperty",
    "type": "string",
    "default": "all",
    "enum": [
    "true",
    "false",
    "all"
    ]
    },
    "sysparm_input_display_value": {
    "title": "Sysparm Input Display Value",
    "description": "Flag that indicates whether to set field values using the display value or the actual value",
    "type": "boolean",
    "default": false
    }
    },
    "required": [
    "short_description",
    "assigned_to"
    ],
    "order": [
    "short_description",
    "assigned_to",
    "urgency",
    "sysparm_display_value",
    "sysparm_input_display_value"
    ]
    },
    "blueprintIdentifier": "servicenowIncident"
    },
    "invocationMethod": {
    "type": "WEBHOOK",
    "url": "{{.secrets.SERVICENOW_INSTANCE_URL}}/api/now/table/incident",
    "agent": false,
    "synchronized": true,
    "method": "POST",
    "username": "{{.secrets.SERVICENOW_USERNAME}}",
    "password": "{{.secrets.SERVICENOW_PASSWORD}}",
    "headers": {
    "Content-Type": "application/json",
    "Accept": "application/json"
    },
    "body": {
    "short_description": "{{.inputs.short_description}}",
    "assigned_to": "{{.inputs.assigned_to}}",
    "urgency": "{{.inputs.urgency}}",
    "sysparm_display_value": "{{.inputs.sysparm_display_value}}",
    "sysparm_input_display_value": "{{.inputs.sysparm_input_display_value}}"
    }
    },
    "requiredApproval": false
    }
  5. Click Save.

Now you should see the Trigger ServiceNow Incident (Webhook) action in the self-service page. ๐ŸŽ‰

Create an automation to upsert entity in port

After each execution of the action, we would like to update the relevant entity in Port with the latest status.

To achieve this, we can create an automation that will be triggered when the action completes successfully.

To create the automation:

  1. Head to the automation page.

  2. Click on the + Automation button.

  3. Copy and paste the following JSON configuration into the editor.

    Update ServiceNow incident in Port automation (Click to expand)
    {
    "identifier": "servicenowIncident_sync_after_trigger",
    "title": "Sync ServiceNow Incident After Trigger",
    "description": "Update ServiceNow incident data in Port after triggering",
    "trigger": {
    "type": "automation",
    "event": {
    "type": "RUN_UPDATED",
    "actionIdentifier": "servicenowIncident_trigger_incident_webhook"
    },
    "condition": {
    "type": "JQ",
    "expressions": [
    ".diff.after.status == \"SUCCESS\""
    ],
    "combinator": "and"
    }
    },
    "invocationMethod": {
    "type": "UPSERT_ENTITY",
    "blueprintIdentifier": "servicenowIncident",
    "mapping": {
    "identifier": "{{.event.diff.after.response.result.number}}",
    "title": "{{.event.diff.after.response.result.short_description}}",
    "properties": {
    "category": "{{.event.diff.after.response.result.category}}",
    "reopenCount": "{{.event.diff.after.response.result.reopen_count}}",
    "severity": "{{.event.diff.after.response.result.severity}}",
    "assignedTo": "{{.event.diff.after.response.result.assigned_to.link}}",
    "urgency": "{{.event.diff.after.response.result.urgency}}",
    "contactType": "{{.event.diff.after.response.result.contact_type}}",
    "createdOn": "{{.event.diff.after.response.result.sys_created_on}}",
    "createdBy": "{{.event.diff.after.response.result.sys_created_by}}",
    "isActive": "{{.event.diff.after.response.result.active}}",
    "priority": "{{.event.diff.after.response.result.priority}}"
    }
    }
    },
    "publish": true
    }
  4. Click Save.

Now when you execute the webhook action, the incident data in Port will be automatically updated with the latest information from ServiceNow.

Let's test it!โ€‹

  1. Head to the self-service page of your portal

  2. Choose either the GitHub workflow or webhook implementation:

    • For GitHub workflow: Click on Trigger ServiceNow incident
    • For webhook: Click on Trigger ServiceNow Incident (Webhook)
  3. Fill in the required details:

    • Short description of the incident
    • User the incident should be assigned to
    • Urgency level
    • Any additional parameters required
  4. Click on Execute

  5. Done! Wait for the incident to be created in ServiceNow