Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to create sub-task with a field and assignee information coming from a predfined confluence page



I have a requirement where subtasks are supposed to be auto-created when a new parent is created in jira but the catch is that a single line text field(name) and assignee on the sub-task must be populated from a confluence page table with key value mappings. So if there are 10 rows then 10 sub-tasks should be created.

Name Assignee

IRR bngda

ABC dlynch

I have scriptrunner for Jira but not for confluence so finding it difficult to approach a solution for this.

I have created sub-task using script post function create sub-task and additional issue actions for small automations but this i am not able to think as number of sub-tasks cannot be added in advance and will depend on confluence page table length.

We don;t want user to select Name and Assignee manually on a jira ticket so maintaining list in confluence and not via custom field in jira. But if there is an easy way to do this completely in jira also then it would be great. Also maintaining list in jira makes it easy for non admin users to manage it.


Any help guidance would be highly appreciated!



2 answers

1 accepted

0 votes
Answer accepted

While I can see Ravi's point, I'm not sure I completely agree.

I think having a confluence page as an easy place for users to maintain a list of values is a good approach in my opinion.

There are some limitations and possible complications to be aware of, but it's definitely better than hardcoding the key-value mapping and then requiring the jira admin to update frequently.

Here is a short script to get you started to get values from a table in a confluence page using application link authenticated request:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.applinks.JiraApplicationLinkService
import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType
import org.jsoup.Jsoup

def pageId=35241928 //put your own page ID here

def appLink = ComponentAccessor.getComponent(JiraApplicationLinkService).getPrimaryApplicationLink(ConfluenceApplicationType)
def conflUrl = appLink?.displayUrl
def applicationLinkRequestFactory = appLink.createAuthenticatedRequestFactory()

def pageUrl = "$conflUrl/rest/api/content/$pageId?"

def request = applicationLinkRequestFactory.createRequest(Request.MethodType.GET, pageUrl )
def response = request.execute()
def soup = Jsoup.parse(response)
def map ='table')[0].select('tr').tail().collectEntries{row->

Some assumptions:

  1. Confluence and Jira are linked via application links (I think OAuth with impersonation is required)
  2.  The page only has a single table. If you have more than one, you can change the index (currently retrieving table index 0). Beware of inserting new tables in the future and changing the index.
  3. The table contains a header row. We use "tail()" to get everything except the first row.
  4. The table only has 2 columns and the key is in column 0 and the value is in column 1
  5. Keys are unique. if you have more than one row with a specific key, you might want to look at using a different structure for your data.

That's a great script. My only concern was that it relies on Confluence page to exist with a specific table, which is can be tricky sometimes to control because people can edit the page easily.

Thanks for sharing this, Jsoup is a great for parsing.


Hi @Peter-Dave Sheehan 

Thank you for the great help!

So all my key value pairs are in this map and then i need to create a script listener which will run the sub-task creation code inside a loop till the length of this map field? Or maybe a custom script post function inside parent create transition with sub-task creation code inside a loop. How would you suggest me to create the sub-tasks ?

I also need to figure out the code for sub-task creation as out of box create sub-task script runner post function can't be utilized for this requirement, or am i wrong in saying this?

Thank you again for the guidance :) you are helping me convert a requirement which i initially thought may not be possible to implement.




I think if you can use a post function, that's probably more specific than a listener.

But you are correct, the built-in create sub-task feature can't be used as-is.

You need to script the sub-task creation from scratch

map.each{key, value ->
//code to create subtask

You can borrow code for creating subtasks from the library:

hi @Peter-Dave Sheehan 

It worked like a charm, but there is one small issue and it's with jsoup parsing , the key value pairs are having the table descriptor tags associated with them like this <td>IRR</td> <td>bngda</td>

i tried to do a bit research but couldn't find a way to get rid of the tags, do you know how can i get rid of them?

Thanka alot again :)



this is how the page is store on confluence

<table class="wrapped">
<th>Application Name</th>
<th>Application Owner</th>

Here is a jsoup implementation that's more explicit and will get the text elements of each column:

def map ='table')[0].select('tr').tail().collectEntries{row->
   def cols ='td')
0 votes

Hi @Bhupesh Nagda 

Well using Confluence page to store these key-value mapping is also not the best approach IMO.

Since you have ScriptRunner, you can always access your Confluence page (using application link or REST API) and parse that table where you have that key-value mapping. Technically it is possible but relying on a table stored in Confluence to update an Issue in Jira is probably adding too much complexity to your automation.

Doing it entirely from Confluence might be easier though using a macro to call Jira REST API.

I hope it helps.


Suggest an answer

Log in or Sign up to answer

Atlassian Community Events