Forums

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

Trying to create a user report counter field

Eran Sandman January 27, 2025

Hi everyone.

When we open a bug ticket we have a table in the description that states information about the user who reported this issue. When another report is coming we add a new row to the user report table and add information and this can happen multiple times of course. 

I would like to create a field that counts the number of rows in this table using automation. One of the challenges is that having multiple rows in a certain cell can give a wrong calculation. 

Another method that I thought using but have no clue how is somehow to use JIRA forms.

 

Can anyone help me with this? 

2 answers

0 votes
mike mike February 4, 2025

You can use Jira automation with a smart value to count the number of rows in the user report table. One way is to use a regex pattern in a smart value to count line breaks (\n) within the table and adjust for headers. However, if a single cell contains multiple lines, this can lead to inaccuracies. An alternative is using Jira Forms, where each report submission updates a structured form, making it easier to count entries accurately. If Forms support automation triggers, you can increment a custom field whenever a new row is added. Let me know which approach you prefer!  

Download YouTube Premium APK

0 votes
Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2025

@Eran Sandman 

Few questions

  • Is the table having 1 column?
  • Does it have a header?
  • Can you share a sample data to better understand your scenario of multiple rows in certain cell?

Table is stored in markdown syntax format. I am thinking this can be used for parsing and calculating the number of rows in the table.

Eran Sandman January 29, 2025

I managed to count rows, but if for example in the info header somebody entered a long sentence and pressed enter to create a link break, it will be considered as another user report. 

Screenshot 2025-01-29 at 13.02.24.png

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2025

Can you share the rule that you have used?

Using regular expression Lines breaks can be handled.

Eran Sandman January 29, 2025

Oh this is difficult. I tried to use ChatGPT and he gave me every time something else. Do you have a suggestion? 

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2025

I am assuming you would have written the automation rule in JIRA to validate that count of rows is working correctly.

Can you share your working rule, and we can go from there?

Eran Sandman January 29, 2025

{{issue.Description.split("\n").filter(row => row.count("|") > 1).size}}

this is the last one i tried. Assume that description = user reports

Eran Sandman January 29, 2025
{{description.split("\n").size}}

this one work for me for example. But as I said, it won't take into consideration line breaks
Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2025

@Eran Sandman 

Looking it another way as you are interested in reading number of rows in a table.

Table is represented by || for headers and | for body.

For 7 column table, there will be 

  • 2 pipes for header i.e. 14
  • 8 pipes for each row

 

Create this automation rule

snip.png

 

Set smart value variable like this:

snip.png

 

As long as your description has one table, it will work.

Let me know if it works for you

Eran Sandman January 29, 2025

Can I see the full flow of the automation?

I would like that when User Reports is edited that it will count the rows, and update the '# of reports' field that I will create. 

Eran Sandman January 29, 2025

Yes! It works! Thank you so much.

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2025

@Eran Sandman 

Trigger

There are various triggers that can be used depending on the use case. For your requirement you can use either

  • When use Field Value changed and fill the details
  • When Issue Updated

IF Condition

To limit number of issues that the automation hits, you can add a JQL condition 

Then create the smart value as mentioned above.

Finally, Add An Action to edit the custom field i.e. Edit Issue

snip.png

Please accept the answer if the approach is working

Eran Sandman February 13, 2025

Hi! So everything worked fine, but i noticed that some of the tickets are 7 column and some 8 column. Sometimes people add a column for status.

How can I make this automation more adaptable? If there's another header then that it will take this into consideration

 

 

Another issue is:

https://app.intercom.com/a/inbox/t11tttbt/inbox/admin/1111111/conversation/111111111111?view=List   

we usually post links in one of the columns. For example this specific link causes to a table of :

7h x 2r (one row is header) to be 1.25 user reports

Vishal Biyani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 13, 2025

The reason the logic was breaking when saving links is the markdown syntax adds an extra |

Made the formula dynamic and in two steps.

  1. Calculate number of columns
  2. Calculate number of rows

Number of columns

Create a variable (NumberOfColumns) with following expression:

{{#debug}}{{#=}}{{issue.description.substringBeforeLast("||").replace("||", "~").split("~").size}} -1 {{/}} {{/}}

 

Number of rows

Create a variable (NumberOfRows) with following expression:

{{#debug}}{{#=}} ({{issue.description.substringAfterLast("||").replaceAll("\[.*?\]", "[]").replaceAll("[^|]", "").length}} /({{NumberOfColumns}} + 1)) {{/}} {{/}}

 

The formula is bit complex but if you are familiar with regex would be simple to understand.

Please test this out and let me know if you find any other edge condition

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events