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

Auto-populate description (or preview) based on scripted field

Current situation:

Transition screen with a scripted field (issue picker) "Existing Reported Issue", and a 'normal' custom field "Public bug description":

Schermafbeelding 2021-01-12 om 12.15.56.png

Is it possible to auto-populate "Public bug description" based on the issue picked at "Existing Reported Issue"?

So, for example:

- chosen "Existing Reported Issue" has description "XYZ"

- Public bug description will be auto populated "XYZ"

- if another Existing Reported Issue is chosen, the Public bug description will be "overwritten".

If that's not possible, some kind of preview of the Description field is also fine.



1 answer

1 accepted

Hi Berry,

You can achieve this with setFormValue() in Scriptrunner Behaviour.

Here's the sample script which is applied in Behaviour > Fields > (Your issue picker field):

def issuepicker = getFieldById(getFieldChanged()) 
def multitext = getFieldByName("Multi Text Field")

//Get the issue picker field's value
String issuepickerValue = issuepicker.getValue()

//To check the issue picker field's value in logs
log.error("issuepickerValue: $issuepickerValue")

if (issuepickerValue == "SUN-5") {
}else if (issuepickerValue == "SUN-6") {

You can refer to this document for more information on adding a default description with Behaviour. 

Hi JJ, thanks for the info!

However, I'm still a bit stuck in the implementation. Is it possible to have a quick screen share session?

Cheers, Berry.

Hi Berry,

Apologies that we can't have a screen share session regarding the issue. 

But you can attach the screenshots with the explanations on where you’re stuck with. I'll take a look at it when I'm available.

No problem. To be honest, I'm really a noob concerning Behaviours, so I "just" copy/pasted your script with minor adjustments. Not sure what to do next..

See the video at:


You're almost there. You'll need to change the "SUN-5" and "SUN-6" to the issue keys that have been selected in your Issue Picker field.

Just some minor changes for this part:

//If you've selected "RI-5162" in your issue picker field
if (issuepickerValue == "RI-5162") {
multitext.setFormValue("RI-5162 - test 23 dec 3")
}else if (issuepickerValue == "RI-5163") { //If you've selected "RI-5163" in your issue picker field
multitext.setFormValue("RI-5163 - test 23 dec 4")

Also, in the Behaviour Mappings please choose "Use project/issuetype mapping" mapping type. The service desk mapping type should only trigger the behaviour on the customer portal. 

Hope this help! 

Thanks, Unfortunately I still do not see the expected behavour:

One more question as I don't exactly understand why/how I should change the mentioned issue key's in the script. Because it could be any random issue key that people will select in the field Existing Reported Issue. 

In your screencast, I can see you're mapping to project "Reported Issues" and transition the status in the project "Uniface Service Desk".

Please try to map to the project "Uniface Service Desk" with "Use project/issuetype mapping" mapping type.

I don't exactly understand why/how I should change the mentioned issue key's in the script. 

You'll need to give a condition/command in order to customize the default value for text field based on issue picker value. The issuepickerValue stored the selected issue picker field value. So when you have got this condition in your script:

if (issuepickerValue == "RI-5162") { 
multitext.setFormValue("RI-5162 - test 23 dec 3")

If you've selected issue picker field with RI-5162, then the text field value is pre-filled with "RI-5162 - test 23 dec 3". 

But I guess you wanted to auto-populate the text field value with same as the selected issue picker value. You can just remove the if-else condition and set the text field with issue picker field value.

import com.atlassian.jira.component.ComponentAccessor

def issuepicker = getFieldById(getFieldChanged())
def multitext = getFieldByName("Multi Text Field")

String issuepickerValue = issuepicker.getValue()
log.error("issuepickerValue: $issuepickerValue")

//Get selected issue's summary based on issue picker value
def relatedIssue = ComponentAccessor.issueManager.getIssueByCurrentKey(issuepickerValue as String)

//Set multi text field value with selected issue key and issue summary
multitext.setFormValue(issuepickerValue + " - " + relatedIssue.summary)

You can refer to Adaptavist Library for more information on set form field values from issue in picker.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Apps & Integrations

📅 Partner Webinar & Events Opportunities: July 2022

Hi community 👋, Here is another monthly roundup of the partner-organized events in July 2022. If there is any event missing please let me know in the comments below 🙏 If you're looking for Atla...

29 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you