Auto-populate Description field for specific project in JIRA with a table

Divya Yathagiri Venkata December 1, 2017

I've auto-populated description field with text before. I need help with auto-populating it with a table with columns. Can you give directions on how to achieve this? I tried some javascript code but it doesn't display anything on Create screen.

2 answers

1 accepted

0 votes
Answer accepted
Ignacio Pulgar
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.
December 2, 2017

If you have ScriptRunner, then have a look at how to achieve it through Behaviours:

https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html#_setting_a_default_description

Divya Yathagiri Venkata December 5, 2017

So I should be writing a Groovy script for creating table with columns right?

Ignacio Pulgar
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.
December 6, 2017

You may create a table with wiki notation:

||column 1||column 2||column 3||

|cell value 1|cell value 2|cell value 3|

If you would like to get a more sophisticated table, you may want to have a look at the Table Grid Editor plugin, which lets you create a table as a custom field.

Divya Yathagiri Venkata December 6, 2017

My reply didn't get posted when I tried to hit reply after typing the message here, so I replied under Suggest an Answer field

Jyothi Ravipati October 5, 2021

Hi Divya

 

You told that you have already worked on auto-populated description field with text. Can I know the script once and how and where to run that script.

Could you please mention it ASAP.

Thank you

Jyothi Ravipati October 5, 2021

And I need it for Jira cloud..Are you talking about the same

0 votes
Divya Yathagiri Venkata December 6, 2017

I've already tried this before I raised a question here. I've enabled wiki style renderer to the description field which shows a table when I put in the above wiki notation (it actually looks more like separated rows with columns rather a table). But what I need is to auto-populate a table with column headers in the description field on the create screen. Earlier, I've auto-populated text in description field by putting javascript under the below path.
JIRA administration --> Issues --> Fields --> Field Configurations --> Description [Wiki Style Renderer] --> Edit --> Edit Field Description: Description --> place the javascript under Description box here

In the same way, how do I modify this javascript to populate the description field with a table having column type headers such as: Column1 | Column2  | Column3 | Column4  | Column5 | Column6

I went through your first response and tried using a behaviour. I was successfully able to display text in Description field using a behaviour. But, I need to know the function to be used to populate a table in the description field. I have googled and all that I see is to how to CREATE TABLE in a database but I don't need that. All I need is to create a simple table with rows and columns having column headers so that users can input their details into the table.


I've also checked the Table Grid Editor plugin but I need this for the system field (Description) but not for custom fields in my case.

Ignacio Pulgar
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.
December 6, 2017

Have you tried the wiki notation of a table in conjunction with a behaviour? That way you may define one or more tables with the appropriate column headers for any project & issue type combinations.

Divya Yathagiri Venkata December 6, 2017

Expected.pngActual.png

Divya Yathagiri Venkata December 6, 2017

I tried that, pls see the results above

Divya Yathagiri Venkata December 6, 2017

first is expected, second is actual

Ignacio Pulgar
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.
December 6, 2017

May you click on the Text tab of the actual result to see its wiki notation?

Ignacio Pulgar
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.
December 6, 2017

Try copying this in Text mode:

||column 1||column 2||column 3||
|cell value 1|cell value 2|cell value 3|
Ignacio Pulgar
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.
December 6, 2017

I suspect you have one extra carriage return between both lines, which is causing the weird display of the table. Just remove the empty line between the column headers and the first row and the table will be displayed correctly.

Divya Yathagiri Venkata December 20, 2017

Thanks this works!

Divya Yathagiri Venkata January 8, 2018

Now, I use similar script for a custom field but the text doesn't appear in the field on the create screen. Can you please help?

Ignacio Pulgar
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 8, 2018

I would need some info to help you further:

  • Did you follow this step by step guide, adapting it to your custom field?
  • May you paste here your script?
  • Did you map the behaviour to the correct project(s) and/or issue type(s), and performed your tests accordingly?
Divya Yathagiri Venkata January 9, 2018

Yes, I did follow the steps in the link and it worked for description

Below is my script for a new custom field called ServiceRequestDetails

def srd = getFieldById("ServiceRequestDetails")

def defaultValue = """Please enter the values for""".replaceAll(/    /, '')

 

I mapped the behavior to the correct project and issue type. The ServiceRequestDetails field is seen on the screen but it is empty. This is a multi-line text field.

Ignacio Pulgar
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 9, 2018

May you try this alternative line?

def srd = getFieldByName("ServiceRequestDetails")

Divya Yathagiri Venkata January 11, 2018

This doesn't work too

Divya Yathagiri Venkata January 11, 2018

Behavior.png

Ignacio Pulgar
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 12, 2018

Reviewing the docs for Description:

https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html#_setting_a_default_description

There's no need to select the fields, as they are implicit in the code.

Perform the following actions, and try again after each of them:

  • remove the selection of both fields
  • (if the previous action do not work) add both codes to the same initialiser function
Divya Yathagiri Venkata January 12, 2018

SRD table.png

Divya Yathagiri Venkata January 12, 2018

Yes, I have tried this earlier but with getFieldById instead of getFieldByName. So it didn't work earlier and it works now!


But looks like I have a problem displaying a table in the field. It must be a wiki renderer issue but am not able to fix that. The same script works for Description field and it shows a table but it doesn't display the table for the Service Request Details field. So issue is not with the script but with the field.


I've actually tried to put in a default value by configuring the custom field 'Service Request Details' itself. It worked it displayed table with content but it works intermittently - it doesn't display table and within few mins if I hit create issue button it again does display. The behavior script didn't even show the table once. Basically the Visual and Text tabs are not seen on the Service Request Details field unlike Description. Do you know how to turn that on?

Divya Yathagiri Venkata January 12, 2018

Also I want to know if we can display different contents in the Service Request Details field for one project when a different Request Type is chosen. Request type is a Dynamic Select (using Intenso Dynamic Forms) Custom field.

Divya Yathagiri Venkata January 15, 2018

Regarding my query about Service Request Details field I have turned on the Wiki Renderer but it works on and off. Sometimes it displays a table and sometimes just as plain text.

Ignacio Pulgar
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 15, 2018

Then I'd open a help request with ScriptRunner Support:

marketplacevendorsupport@adaptavist.com

Should you find out how to fix it, please, post the solution here so that other community members with the same problem can obtain the correct answer here.

Best regards

Suggest an answer

Log in or Sign up to answer