Forums

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

How do you clear description when changing project or issuetype?

Tim Perrault
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 Champions.
July 30, 2019

I was trying to set a default description, which I was able to do. My problem is when I change the issuetype the description is carried over. This also occurs when I change the project. I have the mapping set to a single project and single issue type. I was even trying to get past the issue with putting some validators in script that would check the issue type, but still no success. 

 

Jira v7.13.1

ScriptRunner v5.5.9 

 

def desc = getFieldById("description")

def defaultValue = """
{color:#505f79} _Complete this Story description using the following:_ {color}

*As a* <"role">

*I need*: <requirement or feature>

*So that* <goal/value>

"""

def accept = getFieldByName("Acceptance Criteria")

def acceptValue = """
{color:#505f79} _Include the Acceptance Criteria for this Story in the form of "Test Scenarios". If the criteria is documented elsewhere, provide the link._{color}

Test Scenario:

Test Scenario:

"""

if ((getActionName() == "Create") && (issueContext.issueType.name =="Story")) {
desc.setFormValue(defaultValue)
accept.setFormValue(acceptValue)
}

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Alex Programmer
August 12, 2019

Another function: getFieldByName("Email") gives a result, so I have a solution. Why getFieldById("email") doesn't function, is still unclear.

Deleted user
August 12, 2019

Hi Alex

getFieldById only works with default fields (such as description, summary, etc.) or in the form of getFieldById("customfield_XXX") where the XXX is the actual ID of the custom field.

When you are configuring a custom field, you can find its ID by looking in the URL. There will be a number there. Replacing XXX with the number should fix your issue.

Why this works like this is because you can have 2 custom fields with the same name, so the custom field name isn't actually a good fit as an ID as you'd expect an ID to be unique.

Kind regards
Jorden

TAGS
AUG Leaders

Atlassian Community Events