Issue with script runner after adding behavior in the project

Deleted user March 15, 2018

Hi Team,

I have written below script to add behavior in the description box.

def desc = getFieldById("description")
def defaultValue = """
h5.Initial situation:
h5.Activity:
h5.Expected result / target state:
h5.Monitored result / current state:
h5.Consequence (opt.):
h5.Workaround (opt.):
h5.Used logical or physical test data (opt.):
""".replaceAll(/ /,'')
if (! desc.getValue()) {
desc.setFormValue(defaultValue)
}

 

The problem is when I am going to create an issue in a project behavior is not coming in the visual panel in the description box and when I moving to text tab and removing one space from there and I moved to visual tab then the behavior is coming in the description box. 

Can somebody help me to fix this issue?

Thank You

Shubhanshu Trivedi

1 answer

1 accepted

1 vote
Answer accepted
Brittany Wispell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 19, 2018

Hey @[deleted] 

First you'll want to limit it to a specific issuetype (that way it doesn't show up on all your create issue screens. unless you want it on all) I'm not exactly sure what problem you are having with the text tab & visual panel could you send a picture? Here's some code for the behavoiur.

/*
* Code to be placed as an initializer function
*/

// Get a pointer to the description field
def desc = getFieldById("description")

// Get a pointer to the issue type field and get its value
def issueType = getFieldById("issuetype")
def issueTypeVal = issueType.getValue()

// If the issue type equals issuetype ID
if (issueTypeVal == ****) {

def defaultValue = """
h5.Initial situation:
h5.Activity:
h5.Expected result / target state:
h5.Monitored result / current state:
h5.Consequence (opt.):
h5.Workaround (opt.):
h5.Used logical or physical test data (opt.):
""".replaceAll(/ /, '')

if (!underlyingIssue?.description) {
desc.setFormValue(defaultValue)
}
// If any other issue type ID is returned set the description to a blank value
} else if (issueTypeVal != ****) {
desc.setFormValue(" ")
}
Deleted user March 19, 2018

Hi @Brittany Wispell,

Thanks for your help. I used the same code which you provided me still I am facing the same problem.

I'll explain you one by one step.

Img1.GIFIn above image, I logged in and I am creating an incident by adding the behavior in the description box and particular issue type, In the visual panel, behavior is not coming for the 1st time.

Now if I'll switch the text panel like below image behavior is coming and if I'll remove the backspace from the last line and again if I'm switching to the visual behavior is reflecting in the visual panel. img2.GIF

Removing backspace

img3.GIFSwithcing to Visual

img4.GIFSo my question is after removing the backspace from text behavior is working why it's not working from the initial state and 2nd-time onwards it's working fine. No need to do the thing if I am creating the ticket for the 2nd time.

Thank You

Shubhanshu

Brittany Wispell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 20, 2018

Hey! @[deleted]
Try this. I removed the enter at the beginning of """"h5.Initial situation: and end :"""".replaceAll(/ /,' ') . The images below you'll see no spaces. 

Try that and see if it works for you. It worked for me. 

/*
* Code to be placed as an initializer function
*/

// Get a pointer to the description field
def desc = getFieldById("description")

// Get a pointer to the issue type field and get its value
def issueType = getFieldById("issuetype")
def issueTypeVal = issueType.getValue()

// If the issue type equals issuetype ID
if (issueTypeVal == 10001) {

def defaultValue = """h5.Initial situation:
h5.Activity:
h5.Expected result / target state:
h5.Monitored result / current state:
h5.Consequence (opt.):
h5.Workaround (opt.):
h5.Used logical or physical test data (opt.):""".replaceAll(/ /,'')

if (!underlyingIssue?.description) {
desc.setFormValue(defaultValue)
}
// If any other issue type ID is returned set the description to a blank value
} else if (issueTypeVal != 10001) {
desc.setFormValue(" ")
}

 

Screen Shot 2018-03-20 at 2.45.58 PM.pngScreen Shot 2018-03-20 at 2.45.53 PM.png

Deleted user March 21, 2018

Hi @Brittany Wispell,

Thanks for your reply.

After removing the space from the script Still, I am facing the same problem.

It's not working for the 1st time in the visual section.script.JPG

 

Shubhanshu Trivedi

Brittany Wispell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 21, 2018

Try removing the other space. Behavoiurs are very finicky sometimes. Sorry about that.  

 def defaultValue ="""h5.Initial situation:
Deleted user March 23, 2018

Hi @Brittany Wispell,

Thank You So Much for your help.

Now it's behaving properly, Sometimes it's not.

As you already mention that behaviors are very finicky sometimes.

Once again thank you so much.

Have a good day.

Shubhanshu trivedi

Brittany Wispell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 23, 2018

You're very welcome! 

If you could please accept this answer as a solution that would be great! 

Have a good one!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events