Jira spoke - upload attachment from Jira to Service now


Description

You would like to retrieve an attachment that was uploaded to Jira and upload it to ServiceNow.

Instructions

First step is to follow this article and this documentation.

Then you will create the actions and Flow logic that will bring you to this final setup:

Note that this is an example that should give you guidance on how to achieve this step. It will be up to you to configure the actions and steps are per your business requirements, and Technical Support does not assist in the implementation per se. 

Note that points like A and B would need to be created before points like 1,2,3,4 but for  avoiding confusion I am presenting here the subflow setup, while  the setup of the actions constituting it will be shown towards the end.

 We will create our example on incident record. You can adapt it to your needs.

These are the steps. 

1. After configuring  the Bi-directional Jira Integration you should have the below 2 setup in place: 

2. You would then select "Add Flow Logic" and chose "If"

You would then configured as below:

3. You would then press on the small "+" sign as below:


and configure "Get Attachment Details" action as below:

Note: The action should be created before this. Please follow step "A" that will be detailed below for creating this action.

4. Then you would click again on the small "+" sign and configure the "Save attachment from Jira" action as below:

Note: The action should be created before this. Please follow step "B" that will be detailed below for creating this action.


As mentioned, in order to be able to configure steps 3 and 4 you first need to have the actions created. 

Here is how to configure them:

A: Get Attachment Details Action.

A.1. See input:

A.2. See script step:


This is the script:

(function execute(inputs, outputs) {
var payload = JSON.parse(inputs.payload);
  outputs.attachment_name = payload.attachment.filename;
    outputs.attachment_url = payload.attachment.content;
})(inputs, outputs);


A.3. See outputs:


B. Save attachment from Jira action.

B.1. See input:

B.2. See script step:


This is the script:

(function execute(inputs, outputs) {
  var result;
  var url = inputs.conn_url;
     var baseUrlPattern = /^https?:\/\/[a-z\:0-9-.]+/;
    var match = baseUrlPattern.exec(url);
    if (match != null) {
        result = match[0];
    }
    if (result.length > 0) {
        url = url.replace(result, "");
    }
  inputs.file_name = inputs.file_name.replace(/ /g,"+");
  if(inputs.file_name == "" || inputs.file_name == null)
    outputs.name = "MyFile";
  else 
    outputs.name = inputs.file_name;
outputs.resource_path = url;
})(inputs, outputs);


B.3. This is the REST step:


Test now by adding an attachment in one of the Jira records.
With this setup in place you should have a new incident create in ServiceNow,and an attachment should be also attached to the new record.