Forums

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

Script Runner is not behaving properly.

Deleted user June 18, 2018

Hello Team,

We are using behavior in one of our Jira project for Bug Issue type. We are using a script in the Description field to get predefined data. 

After creating the issue whenever we are trying to edit an existing issue, the description gets reset to the default text and all user filled in the text is deleted.

I am attaching my script here. Please suggest.

def desc = getFieldById("description")
def issueType = getFieldById("issuetype")
def issueTypeVal = issueContext.issueType.name

if (issueTypeVal == "Bug") {
def defaultValue = """*<Description>*
*Steps to reproduce:*
*1.*
*2.*
*3.*

*Actual result:*

*Expected result:*""".replaceAll(/ /, '')

if (! underlyingIssue?.description) {
desc.setFormValue(defaultValue)
}
} else {
desc.setFormValue(" ")
}

 

2 answers

1 accepted

1 vote
Answer accepted
Mark Markov
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.
June 19, 2018

Hello @[deleted]

If you need different logic on create screen and edit screen, you must restrict code execution depending on current action (create or edit).

function that helps you to achive that

if (getActionName() == null) // for edit screen

if (getActionName() == "Create") // for create screen
Deleted user June 20, 2018

Hi @Mark Markov,

I used your function in our code we achieved our end result only one behave a noticed. When I am moving to different issue type at the time of issue creation (Bug to some other issue type) behavior is not going, I have to click on the Visual tab then the description values are vanishing in the creation screen.

Can you please suggest?

Shubhanshu Trivedi

Mark Markov
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.
June 20, 2018

It seems like you place your code in Initialiser Function

Code in this function runs only once form load. Map your code to Issue Type field and it will be run every time field changes. Like this

Снимок экрана 2018-06-20 в 17.10.30.png

Deleted user June 20, 2018

@Mark Markov

Thanks For your suggestion.

It works.

0 votes
Roland Holban (Adaptavist)
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.
June 18, 2018

Can you send me a screenshot of your behaviour config?

Looking for this screen:

Screen Shot 2018-06-18 at 11.13.33 AM.png

Deleted user June 18, 2018

Capture.JPG

Roland Holban (Adaptavist)
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.
June 18, 2018

I cannot reproduce your issue.

  1. I created a behaviour with the same script, same config as yours
  2. I create a "Bug" issue and add additional text to pre-filled description
  3. I go to edit the issue and description doesnt change

What version of SR and JIRA are you on?

Deleted user June 18, 2018

Hi @Roland Holban (Adaptavist),

SC-5.3.26

Jira-7.2.13

Try to edit other existing issues types in your projects not only Bug issue type.

BR,

Shubhanshu

Roland Holban (Adaptavist)
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.
June 18, 2018

When I edit other issue types the description gets cleared completely because of:

} else {
desc.setFormValue(" ")
} 
Deleted user June 18, 2018

Yes, Roland. I am using this to omitting description when I am changing the issue type at the time of issue creation. If I'll remove these lines then description text is the default for all the issue types.

Shubhanshu

Roland Holban (Adaptavist)
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.
June 19, 2018

I tried downgrading my SR and JIRA to your specific versions and I still cannot seem to reproduce.

If I edit an existing issue of issue type not bug, the description gets cleared correctly because the else clause triggers:

} else {
desc.setFormValue(" ")
}

If I try to edit an existing issue of issue type bug, the description doesnt clear because this checks for an already existing description before filling:

if (!underlyingIssue?.description) {

Do you you have any other behaviours that might be doing this?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events