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

Behaviours: Scriptrunner and Insight for JIRA

I am doing field behaviors using scriptRunner and hit some sort of challenging problem.

The requirement is that when the user selected "VSC" from the drop down(insight object single select field), then other fields show appear.  But for some reason they don't show VSC is selected.  Please assist.

Below is the code:

def businessUnit = getFieldById("customfield_10622")


def selection = businessUnit.getValue()

def application = getFieldById("customfield_11001")
def serviceAffected = getFieldById("customfield_11002")
def applicationVersion = getFieldById("customfield_11008")
def customer = getFieldById("customfield_11007")

if(selection == "VSC")
{

application.setHidden(false) //show the fields
application.setRequired(true) //set the fields to be required
application.setHelpText("This field is required, please provide information") //Helptexts

def applicationSelection = application.getValue()

if((applicationSelection == "MYSILS") || (applicationSelection == "PPECB") || (applicationSelection == "MYEXCHANGE"))
{
customer.setHidden(false) //show the customer field
serviceAffected.setHidden(false) //show the services affected field

}
else
{
customer.setHidden(false) //show the customer field
serviceAffected.setHidden(false) //show the services Affected field
applicationVersion.setHidden(false) //show the Application version field
}

}else{

//hide the fields
application.setHidden(true)
serviceAffected.setHidden(true)
customer.setHidden(true)
applicationVersion.setHidden(true)


}

2 answers

1 accepted

1 vote
Answer accepted

Shawn,

I think this is because Insight custom fields are not compatible with ScriptRunner behaviours. We have been working on implementing compatibility: https://productsupport.adaptavist.com/browse/SRJIRA-2563

I would suggest following that issue to see when the compatibility is released.

Regards,

Josh

Hi, I manage recently to use the insight fields in a behavior scriptrunner configuration.

I use the key of the object in the if statement instead of the string of the selected choice.

If the "required field" is set either to 'DD-166215' or 'DD-166253', then the text field will be set to visible and required.

Here is my example, hope it can guide you too.

it is set as a script on the field1 in behavior, ( not the initializer section)

 

def requiredField = getFieldByName('field1')
def textField = getFieldByName('field2')
def requiredValue = requiredField.getValue()

if (requiredValue.toString() == 'DD-166215' || requiredValue.toString() == 'DD-166253') {
  textField.setRequired(true)
  textField.setHidden(false)
} else {
  textField.setRequired(false)
  textField.setHidden(true)
}

one more thing,

To see the keys of the selected objects in the insight field.

Go to an issue that has these fields available on the screen, change the field on the issue. Go to the activity tab All to see all changes on the issue, there you will see the keys of the object you just changed. 

Hi

Thanks for the example. I tried it out and i gor one issue. It seems like it doesnt react to the first selection. Let me try to describe it

I have a custom field mapped to and insight object type. No Default value and the above behaviour script on it. When I select the first time theres no reaction. As soon as a I make the second selection The behaviour starts reacting.

Does it make sense?

Any ideas

Regards Michael

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

82 views 0 4
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