ServiceNow and iHub Cloud

Short guide for integrating Jira Cloud With ServiceNow using iHub Cloud

 

Create App in ServiceNow

Decide on authentication type, select OAuth2 or JWT.

JWT

Setup Credentials in iHub Cloud

OAuth2

  1. Navigate to Credentials

  2. Click Add Credentials

  3. Select OAuth2

  4. Click Save

  5. Select Grant type: Resource Owner Password Credentials Grant

  6. Enter the following fields;

    1.  Authorization Url: <instance-url>/oauth_auth.do

    2.  Username: the integration user

    3. Password: the integration password

    4. Client Id: from Create App in ServiceNow step

    5. Client Secret: from Create App in ServiceNow step

    6. Scope: leave blank

  7. Click Save

Copy the callback URL on the credentials page and go back to the ServiceNow app and paste in the callback and save that.

  1. Click “Click here to Authorize” button

 

 

Send Issue data to ServiceNow from Jira Cloud

Create a Incident

  1. Create a new Integration

  2. Set a trigger like Issue Created and provide a simple JQL

  3. Create an Action

  4. Select POST as method

  5. Enter url to your instance example https://dev262540.service-now.com/api/now/v1/table/incident

  6. Select the Authentication created in the above step

  7. Enter the Body

    { "short_description": "{{issue.summary}}", "description": "{{{toJSON issue.fields.description}}", "urgency": 2 }

 

Optional step, if you wan to combine Issue Created Event and Issue Updated Event then you need to add a data condition

Path

Operand

Value

Path

Operand

Value

$.webhookEvent

EQUALS

jira:issue_created

This will prevent issue update events to trigger the create actions.

 

 

Saving ServiceNow incident number on the ticket

  1. Create an Action, select template Update Issue ( this for convenience you may create a empty action and configure it if you like)

  2. Enter a name, like Update issue

  3. Select the custom field that you like to put the incident number into, enter the value "{{result.sys_id}}"

 

 

Upload attachments to Incident

ServiceNow attachment API can only receive one file at the time, hence we will iterate over the unsent attachments and send one at the time.

  1. Create an Action

  2. Select the create incident as parent

  3. Select POST as method

  4. Enter url to your instance example https://dev262540.service-now.com/api/now/attachment/upload

  5. Select the Authentication created in the above step

  6. Click Condition, this to prevent this action to be triggered if there is no attachment added and prevent already sent files to be sent.

  7. Define the Condition. Fill in the following details:

    • JSON Path: Enter $.attachments.unsentFile.length

    • Operand: Select "Greater than"

    • Value: 0

  8. Click Advanced tab and enter the iteration path $.issue.fields.attachment to make this action run onetime per attachment found on the ticket.

  9. Enter the Body

    { "table_sys_id":"{{result.sys_id}}", "table_name":"Incident", "file":"{{attachments.unsentFile}}" }

 

Issue Update send attachments

Want to upload an attachment whenever a ticket is updated?

This builds on the previous tutorial. We'll make a copy of the "upload attachment to incident" action and move it to the top level (root level) of your integration flow. This way, the attachment uploads every time the ticket changes.

Here's how to do it:

  1. Duplicate the upload action: Find the "upload attachment" action you already have. Make a copy of it.

  2. Move it to the top: Drag the copied action to the very top of your flow. This is the root level.

  3. Click advance tab, remove the iteration, make the field blank.
    This due to that issue attachment event sends a request per file.

  4. Set the upload condition: Click on the copied action. We need to tell it to only run when a ticket is updated. Find the "Conditions" tab and choose Data Condition and add $.webhookEvent EQUALS jira:issue_updated

  5. Tell it where to upload: Check the body and the "table_sys_id" property. This tells the action where to upload. Change this value to use the custom field that holds the information about where the attachment should go.

 

 

That's it! Now whenever someone updates a ticket, the copied action will upload the attachment based on your custom field.