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

JIRA & ScriptRunner Cloud: How to update Description field on creation of a certain issue type?

I am using JIRA cloud and installed ScriptRunner from the Atlassian Marketplace.

I was wondering how I can use ScriptRunner to pre-populate the Description field when creating a new ticket of a certain project / issue type?

In Script Listeners, I can only select "Issue created" for the "on these events", but I assume that is already too late and only executed when the issue was submitted through the "Create" button?

What I would need is took hook into an even such as "onCreate"? How do I achieve this?

And this is how my script would look like:

def projectKey = project.key as String
logger.info("Creating new issue in ${projectKey}")

logger.info("Checking for issue type Initiative")
def issueTypesReq = get("/rest/api/2/issuetype").asObject(List)
assert issueTypesReq.status == 200
def taskType = issueTypesReq.body.find { it.name == "MyCustomIssueType" }
assert taskType // Must have an issue type named Initiative

logger.info("Updating Description field")
def result = put("/rest/api/2/issue/${issue.key}")
.header('Content-Type', 'application/json')
.body([
fields: [
description: "h2. Description:\nBlabla\n\n"
]
])
.asString()

Can anybody give me a hint where / how to place this?

2 answers

1 accepted

2 votes
Answer accepted

Jira Cloud does not yet support the functions that Scriptrunner on Server does that could help you with this (Behaviours).

As you suspect, the listener is too late - the create event is fired when the human clicks the "create" button and commits the data they've entered (including description).  Your script, if run as a listener, would overwrite what they've typed into the description.

hi @Sabine Do-Thuong 

Additional information to this, you can use the Issue Created event to perform actions after an is issue. You will need to use a Post Function script if you want it to happen when an issue is created as a for all events for listeners occur after the event that triggers them to happens. 

The description is just a string and you can refer to the Create Task example on the Script Console page for an example syntax needed to set the description. 

Hope this helps.

Thank you.

Kind Regards

Kate

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...

171 views 6 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