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
Navigate to Credentials
Click Add Credentials
Select OAuth2
Click Save
Select Grant type: Resource Owner Password Credentials Grant
Enter the following fields;
Authorization Url: <instance-url>/oauth_auth.do
Username: the integration user
Password: the integration password
Client Id: from Create App in ServiceNow step
Client Secret: from Create App in ServiceNow step
Scope: leave blank
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.
Click “Click here to Authorize” button
Send Issue data to ServiceNow from Jira Cloud
Create a Incident
Create a new Integration
Set a trigger like Issue Created and provide a simple JQL
Create an Action
Select POST as method
Enter url to your instance example https://dev262540.service-now.com/api/now/v1/table/incident
Select the Authentication created in the above step
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 |
---|---|---|
$.webhookEvent | EQUALS | jira:issue_created |
This will prevent issue update events to trigger the create actions.
Saving ServiceNow incident number on the ticket
Create an Action, select template Update Issue ( this for convenience you may create a empty action and configure it if you like)
Enter a name, like Update issue
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.
Create an Action
Select the create incident as parent
Select POST as method
Enter url to your instance example https://dev262540.service-now.com/api/now/attachment/upload
Select the Authentication created in the above step
Click Condition, this to prevent this action to be triggered if there is no attachment added and prevent already sent files to be sent.
Define the Condition. Fill in the following details:
JSON Path: Enter
$.attachments.unsentFile.length
Operand: Select "Greater than"
Value: 0
Click Advanced tab and enter the iteration path
$.issue.fields.attachment
to make this action run onetime per attachment found on the ticket.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:
Duplicate the upload action: Find the "upload attachment" action you already have. Make a copy of it.
Move it to the top: Drag the copied action to the very top of your flow. This is the root level.
Click advance tab, remove the iteration, make the field blank.
This due to that issue attachment event sends a request per file.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
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.