Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner behaviour initialiser - Clean description when you select another project

Mickaël Orsolino
Contributor
July 3, 2020

Hi,

 

I used the following script to pre-file description field.

 

def desc = getFieldById("description")
def issueType = getFieldById("issuetype")

def defaultStory = """ Story text """
def defaultBug = """ Bug text """
def defnull = """ """

if (getActionName() == "Create"){

if (issueContext.issueType.name =="Story"){
desc.setFormValue(defaultStory)
}
else if (issueContext.issueType.name =="Bug"){
desc.setFormValue(defaultBug)
}
else {
desc.setFormValue("")
}
}

During the creation, If I select another project the description is the same (If it was a story, description is still equal to "Story text"). I have set the behaviour only for one project but there is no clean.

How can I reset the description field on the creation page if we change to another project (not the one selected on the behaviour setting)?

 

Thank you in advance for your help.

Regards,

Mickael O.

 

1 answer

1 accepted

1 vote
Answer accepted
Italo Qualisoni [e-Core]
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.
July 5, 2020

 

@Mickaël Orsolino ,

 

This is JIRA default behavior to keep the field values in create screen, when you switch projects.

If you want to clear the description value you can create a new behavior with global context with the following initializer:

 

def desc = getFieldById("description")

if (getActionName() == "Create" && issueContext.projectObject.key != "PROJECTKEY"){
desc.setFormValue("")
}

 

You must replace the PROJECTKEY with the project that you are using your behaviour that will set story and bug templates.

I think this approach will work

Mickaël Orsolino
Contributor
July 7, 2020

HI @Italo Qualisoni [e-Core] ,

 

Thank you for your answer. I will test it.

Regards,

Mickael O.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.5.1
TAGS
AUG Leaders

Atlassian Community Events