Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a link to a JQL with a variable

James K_ February 23, 2023

Hello,

I'm attempting to set up an automation that adds a link to a custom field "LINK" when another custom field "CustomOrg" is updated.  The link would only be visible internally to customer support members and provide a link to a JQL query that would search "CustomOrg[Dropdown]" = "VARIABLE", where variable would be the field selected from the dropdown.  The field CustomOrg contains characters such as # and [] so these need escaped if I'm to pass in the link.

Essentially I'm trying to make it easier for agents to be able to quickly see all tickets created by a particular organization, so there may be a more straightforward way to do this that I haven't encountered or thought of.

I've found https://confluence.atlassian.com/jirakb/use-automation-to-edit-link-formatting-on-paragraph-fields-1157182190.html, and attempted to set up something similar, but I'm not seeing my custom field (set up as a Text Field (multi-line), after trying hyperlink).

I don't necessarily want to link all tickets from a customer using the linked ticket option, but rather have the link to the JQL query so an agent can then click on a ticket and then use the forward and back buttons to advance or regress through the JQL results.

Thank you for any assistance.
-James

2 answers

1 accepted

1 vote
Answer accepted
Kai Becker
Community Champion
February 23, 2023

Hi @James K_ ,

could you post a screenshot of the automation you've got so far?

As an alternative, I would suggest the following addon: https://marketplace.atlassian.com/apps/1212709/issue-matrix-for-jira?hosting=cloud&tab=overview

It adds an contextual issue view with issues matching a certain JQL query

James K_ February 28, 2023

I've managed to automate pulling the field value and building the URL for the JQL query, and storing that into a SmartVariable:

pic1.png

Next I'm running a replace on that SmartVariable to encode " ", "/" and "-", as those are present in my customfield_12312 values:

pic2.png

Next I'm formatting the full link with our Jira domain:

pic3.png

Now the only issue I'm having is having the link in my field actually represent the whole link.

Currently, I'm passing in a variable (FormatURL), and I've tried:

  • {{FormatURL.replaceAll("(?<=\|)(.*?)(?=(\]|\|))","$1|smart-link")}}
  • [{{FormatURL}}|Click here]
  • <a href="{{FormatURL}}">Click Here</a>

but to no avail.

I've configured my custom field I'm passing the variable into to use the 'Wiki Style Renderer', but I'm ending up with only a partial link where "https://vardomain.atlassian.net/issues/?jql=" is formatted as a link, but the actual JQL bit isn't included:

pic4.png

In the above I'm just passing in {{FormatURL}}, and if I copy that into my address bar, I can navigate to the correct query.  I'm not entirely sure why my link is being split.

James K_ February 28, 2023

I've done some tinkering and have managed to fix the split URL by using {{CreateURL.encodeURL}} in my second step:

pic1v2.png

Resulting in a complete link:

pic2v2.png

However, I'd like to be able present a simpler link and

  • {{FormatURL.replaceAll("(?<=\|)(.*?)(?=(\]|\|))","$1|smart-link")}}
  • [{{FormatURL}}|Click here]
  • <a href="{{FormatURL}}">Click Here</a>

still don't seem to work.

James K_ February 28, 2023

Fixed, [Click here for all tickets from this customer|{{FormatURL}}] works.

0 votes
Tomasz Rogawski
Contributor
October 6, 2023

Easiest but not prettiest solution for me was to add a sample URL with JQL query from Jira in the template and then replace values with the variables that will change. See an example:

URL Confluence variables and JQL query.png

A user will have to provide these two variables in one place only, resulting in all URLs being updated, and pointing to different Jira items (Story, Tasks, Tests, Bugs).

FYI: The issue I haven't resolved yet is converting URL to Jira table inside Confluence page before/after it is published. Most probably I will have to use a source editor to modify structured macro HTML parameter.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events