How to get current selected jira board via API or Javascript API?

Hey there

I need the information about the current selected board in a jira project. How do I get this information within a Jira Project? I need a way via Jira API or JavaScript AP interface.

Thanks for your help.

Regards, Patrick

Hi @Patrick,

Do you have a web panel being shown in the context of a board where you want to know the board ID? There is a board.id context parameter.

Regards,
Dugald

1 Like

Hi @dmorrow

Thanks for your answer.

What do you mean with a web panel?

I’ve a menu entry in the project sidebar.

See

How do I get this context parameter? My app is completely serverless. There is only a client which communicates with the Jira API.

Regards, Patrick

Hi @Patrick,

It makes it easier for me if you share more details about your app, otherwise I need to make guesses. For instance, sharing a relevant snippet from the Connect descriptor would be helpful.

Regards,
Dugald

Hi @dmorrow

Thanks for your answer.

I am gladly willing to share more information about the app :slight_smile: .

  • In my app I want to save some information on a specific board item. E.g. like this:
 let url = `/rest/agile/1.0/board/${board.id}/properties/feedback/${sprintId}/${userId}`;

  return new Promise((resolve, reject) => {
            if (AP) {
                AP.request({
                    url: url, type: 'PUT', data: JSON.stringify(myData), contentType: "application/json", 
                    success: response => {
                            dispatch(feedbackAdded(response));
                            resolve(response);
                    }, error: response => {
                        reject(response);
                    }
                });
            } 
// ...
  • In this snippet - you see, I need the board id. The ${board.id} should be selected board in the project view (see the screenshot above).

  • You’ll see the project view entry from my atlassian-connect.json here

  "jiraProjectPages": [
            {
                "key": "collect-feedback",
                "name": {
                    "value": "Sprint Feedback"
                },
                "url": "/collect-feedback",
                "iconUrl": "/images/like.png",
                "weight": 0,
            },

Thanks for your help :slight_smile:

Regards, Patrick

Hi @Patrick,

You can modify your descriptor so that your project page is passed the ID of the board. To do this, add the board.id context parameter. Your descriptor will then look as follows:

"jiraProjectPages": [{
  "key": "collect-feedback",
  "name": {
      "value": "Sprint Feedback"
  },
  "url": "/collect-feedback?boardId={board.id}",
  "iconUrl": "/images/like.png",
  "weight": 0,
},

Then the app’s JavaScript can extract the boardId query parameter from window.location.href.

Hope this helps.

Regards,
Dugald

3 Likes

Hi @dmorrow

Perfect - thank you. That’s exactly what I was looking for :smiley: :+1: .

Regards, Patrick

1 Like