New nFeed release: displaying Salesforce data in JIRA issues


Posted by
Christophe PROME

October 10, 2016

At Valiantys, when trying to solve urgent bugs as quickly as possible for our customers, our support consultants often prefer to use the phone rather than JIRA comments.

But this means that our consultants have to dig into Salesforce to find the client’s phone number – what a waste of time and energy!

So they asked why don’t we display the client’s phone number with nFeed? Unfortunately, this wasn’t possible because calls to Salesforce REST API are authenticated with OAuth 2, and nFeed didn’t support this protocol. But that was before…

Now, with nFeed 5.8 you can fetch data from any service using OAuth 2 authentication.

nfeed_oauth_salesforce

Let’s see how you can display Salesforce data in JIRA issues.

Configure the datasource

The first step is to create a new datasource in nFeed that will connect nFeed to the Salesforce REST API.

I won’t go through the details in this article, as everything is explained in our documentation here.

Configure your nFeed field

The second step is to create a nFeed field.

Let’s use the example field Phone number, and add it to the View Issue Screen.

Create nFeed field

Once created, we can configure it from the nFeed configuration page.

Write the SOQL query

Our starting point is the email address of the reporter.

We’ll execute a SOQL query against the Salesforce REST API. SOQL stands for Salesforce Object Query Language. We recommend you look at this documentation to gain a better understanding.

We use the query endpoint and give it a query with the q parameter.

The query in SOQL will be:

SELECT id,phone FROM Contact WHERE Email='$issue.reporter.emailAddress'

As the query is a URL parameter, we need to encode it with encodeURIComponent utility:

query

Locate the data in Salesforce

Now the query is configured, we can test it.

Click on Test query, enter the key of an issue and make sure that the reporter exists in Salesforce CRM.

Query tester

It works – Salesforce returned this JSON:

{
  "totalSize": 1,
  "done": true,
  "records": [
    {
      "attributes": {
        "type": "Contact",
        "url": "/services/data/v20.0/sobjects/Contact/0030Y000001wIAkQAM"
      },
      "Id": "0030Y000001wIAkQAM",
      "Phone": "+1 212-708-9400"
    }
  ]
}

We need to tell nFeed that the data we are interested in is located in the records array.

In the Root path select this array with a JSONPath query:

root-element

If we test the configuration again, this is what we’ll get in the second tab of the query tester:

Query tester, after transformation

This tab displays the JSON after the Root transformation has been applied. It looks like this:

{
  "attributes": {
    "type": "Contact",
    "url": "/services/data/v20.0/sobjects/Contact/0030Y000001wIAkQAM"
  },
  "Id": "0030Y000001wIAkQAM",
  "Phone": "+1 212-708-9400"
}

It’s an array of one element, it contains the contact we are looking for.

We are interested in two attributes:

  • Id is the unique identifier for this record – nFeed will use it to retrieve the record each time the field is displayed.
  • Phone is the data we want to display in our field.

Now let’s configure the JSON columns:

columns

When testing the query, in the third tab of the query tester:

querytester-3

The query configuration is now complete – the next step is to configure how it will be displayed.

The display

The aim of this field is to dispay the data – it isn’t editable.

We select the Read only display mode and choose to display one value only.

We can make this phone number clickable by using the a html tag in the field template.

display

Note: {phone} is a reference to the JSON column defined previously.

Automatically populate an nFeed field upon creation

We want this field to be automatically populated when an issue is created.

The Set a nFeed custom field value post function offers a way to automatically set an nFeed field value during a transition.

This is configured in the Create issue transition:

nFeed post function

Enjoy and relax

Now, each time a customer creates an issue, the phone number field is automatically populated by nFeed.

Result

Ta-dah!

In case you ask… even though nFeed can not (yet) be added to customer requests, this field can be used in any JSD project, and will be visible to the consultants.

With nFeed, our support team can now see, in all issues, the phone number of the reporter. Because the field is connected to Salesforce, any change made in Salesforce will immediately be visible in the issue.

No more time wasting, better SLAs, happy customers and happy consultants!

Wait, there’s more…

In this article, you’ve seen how we use nFeed to fetch important data from Salesforce and display it in a JIRA issue… but that’s not all! With OAuth 2, nFeed can also retrieve data from a wide range of other tools like Google Drive, Zendesk, Google Calendar or Linkedin.

Ready to display Salesforce data in JIRA issues?