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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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.

 

Thanks!

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") {
multitext.setFormValue("sun5")
}else if (issuepickerValue == "SUN-6") {
multitext.setFormValue("sun6")
}else{
multitext.setFormValue(null)
}

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: https://transfer.avisi.works/index.php/s/WafL7wWi5jJSW2j

Thanks.

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")
}else{
multitext.setFormValue(null)
}

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: https://transfer.avisi.works/index.php/s/PBa2jzigz3aEJeR

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
TAGS
Community showcase
Published in Confluence

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

125 views 0 3
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