Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

ScriptRunner - Behaviours - Add default value to description field, unless it's edited.

I was able to add the default description. But, when a user edits the field and clicks away from it, it'll default back to the default value. Is there a way to check if the value has been changed?

 

def desc = getFieldById("description")
def currentIssueType = issueContext.issueType.name
def empty = ""
def defaultValue = """default value""".replaceAll(/ /, '')

def bugDefaultValue = """

default value2""".replaceAll(/ /, '')

if (! underlyingIssue?.description) {
if(currentIssueType == "Epic" || currentIssueType == "Story"){
desc.setFormValue(defaultValue)
}else if (currentIssueType == "Bug"){
desc.setFormValue(bugDefaultValue)
}else{return}
}

1 answer

0 votes
Payne Community Leader Jun 09, 2020

You may consider running your Behaviour only on a Create, and not on an edit. We use this code snippet at the top of a Behaviour for that purpose:

// We wish to run this behaviour only during a Create.
// Per https://scriptrunner.adaptavist.com/5.4.28/jira/behaviours-api-quickref.html#_getactionname :
// getActionName() "Returns the name of the current action if the issue is undergoing a workflow action, null otherwise."
// Create is a workflow action, so it will return "Create Issue" or "Create" (should check for both).
// Edit is not a workflow action, so it will return null.
if (getActionName() == null || !(getActionName() in ["Create Issue", "Create"])) {
return
}

The issue is during the create step. Before the create button is pressed, if the user wanted to clear the default data and add their own, the default data would return upon leaving the description field.

I've decided on using a workaround. Having radio buttons that correlate with whatever default value they want. If they want to enter their own data they would simply choose none.

 

def descriptionField = getFieldById("description")
def radioSelect = getFieldByName("descriptionTest")
def radioSelectValue = radioSelect.getValue()

def text = """

DESCRIPTION DEFAULT VALUE 1""".replaceAll(/ /, '')




def textTwo = """

DESCRIPTION DEFAULT VALUE 2""".replaceAll(/ /, '')

if(radioSelectValue == "Bug Issue Type"){
descriptionField.setFormValue(textTwo)
}else if(radioSelectValue == "Other"){
descriptionField.setFormValue(text)
}else{descriptionField.setFormValue("")}

Hi Raynard, 

have the same issue :-(

Do you already have any solution for this challenge? 

 

Regards, Sergo

No, I decided to use radio buttons that would have the default text. When the radio button is selected the Description field will be populated with whatever corresponds with that button. Also a clear text button if the default description isn't needed.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

328 views 9 7
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