Confluence label change depending on issue epic link.
Asked by Rafa? Grochala:

Hey  

I know that the topic might be misleading, but the case is a bit tricky, so sorry about that ;).

We've got the case where we have to display 3 states on confluence which is Red/Yellow/Green. *(We are going to have 2 Epic Links in Jira Risk and Issue )*

Whenever there is issue created in Jira with specific epic link the status/ label has to change on confluence space

<br />

ex. I have 1 issue with epic link named **Risk** , with that i want confluence status/label to change into yellow label (in more advanced case to display a chart with notification what issue is doing that)  

If there are no issues with Epic Link **Risk or Issue** Confluence has to display **Green Label**   
If there are issues with Epic Link **Issue** Confluence has to display **Red Label**   
If there are issues with Epic Link **Risk** Confluence has to display **Yellow Label**


Answers:
author: Dominic Lagger
body: Hi [@Rafa? Grochala](/t5/user/viewprofilepage/user-id/3499866)

Since you are on confluence server, you could implement your own [user macro](https://confluence.atlassian.com/doc/writing-user-macros-4485.html).

There you could check the epic state and display with HTML and CSS your state in which color you want :)

Regards, Dominic

comments: author: Rafa? Grochala
body: Thanks!  

Although I managed to research a bit about those User Macros. I managed to create one that is showing me all the issues in a specific project but that's about it.   

I'm going with the approach to base on issue count and on that to have a macro to display me status ( Change the Label of a space)  

With that, I'm now stuck since I simply have no idea how to change it to display the numbers instead of a table of issues.  

## [@Param](/t5/user/viewprofilepage/user-id/1345631) ProjectKey:title=Project Key\|type=string\|required=true  
## [@Param](/t5/user/viewprofilepage/user-id/1345631) ProductName:title=Product Name\|type=string\|required=true  
#set($projectKey = $paramProjectKey)  
#set($productName = $paramProductName)  
#set($jiraBaseUrl = "")  

<br />

<br />

<br />

$jiraBaseUrl/issues/?jql=project=$projectKey%20AND%20"Product%20Name"\~"$productName"\|count=true  

Any ideas on how to tackle this?   


author: Dominic Lagger
body: Hi [@Rafa? Grochala](/t5/user/viewprofilepage/user-id/3499866)

I would go another way with a JIRA REST API call.

For that, here is a community post, which helps you to create JIRA REST API call from confluence user macro: <https://community.atlassian.com/t5/Answers-Developer-Questions/Jira-REST-API-Call-from-confluence-page/qaq-p/557196>

With that, you can get the issue you want to analyze with the JIRA API, which is documented here: <https://docs.atlassian.com/software/jira/docs/api/REST/8.5.3/#api/2/issue-getIssue>

And then, you have to find the relevant fields and display your status with HTML and CSS.

User Macros are a little bit "try and error", so sorry for not sending you a proper user macro :) I would also have to try these things out.

Let me know, it this worked. If not, I try to help you with a proper macro, but for this I would need some time.

Regards, Dominic


author: Rafa? Grochala
body: Sure!  

I'll try some experiments with Jira REST API Calls, and let you know how i figured this thing out.   


Tags: confluence-server

jira

server