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

How to show Issue Links based on Resolution selection Edited

What I would like to do:
On a workflow transition screen, expose Issue Links only if the Resolution selected is "Duplicate".

I've been trying to do this with a ScriptRunner Behaviour on the Resolution field. What I have right now hides the Issue Links fields on the correct screen, but it doesn't show them on the Resolution selection.

I don't have a background in Groovy/Java and cobbled this together from googling, so this might be something basic? It's not throwing any errors or warnings when I set up the Behaviour.

What isn't working:

import groovy.transform.BaseScript
import com.onresolve.jira.groovy.user.FieldBehaviours

@BaseScript FieldBehaviours fieldBehaviours

def issueLinkType = getFieldById("issuelinks-linktype").setFormValue("duplicates")
def issueLinkValue = getFieldById("issuelinks-issues")
def resolutionValue = getFieldById(RESOLUTION).getValue()
final String screenName = 'Resolution and Assignee'


if (fieldScreen.name == screenName) {
if (resolutionValue == "Duplicate") {
issueLinkType.setHidden(false)
issueLinkValue.setHidden(false)
}
else {
issueLinkType.setHidden(true)
issueLinkValue.setHidden(true)
}
}

 

1 answer

1 accepted

Hi @Jennifer Smith,

For your requirement, you will need to modify your code slightly. 

First, when you invoke the resolution field, since it is a system field, it should be in lower case, i.e. instead of def resolution = getFieldById("RESOLUTION"), you should use def resolution = getFieldById("resolution") else the behaviour won't take effect.

The second point, instead of using value / getValue() from the Resolution field, you should use formValue / getFormValue().

Below is a print screen from where you can get the details of the values you should use:-

screenshot1.png

When you inspect the element with your browser, you will notice the field id for the Resolution field in lower case, and also, you can see the form value that is used as highlighted in the print screen above.

Below is a working sample code for your reference:-

import groovy.transform.BaseScript
import com.onresolve.jira.groovy.user.FieldBehaviours

@BaseScript FieldBehaviours fieldBehaviours

def issueLinkType = getFieldById("issuelinks-linktype")
issueLinkType.formValue = "duplicates"

def issueLinkValue = getFieldById("issuelinks-issues")
def resolution = getFieldById("resolution")

def resolutionValue = resolution.formValue.toString()
def screenName = "Mark as Done"

issueLinkType.hidden = true
issueLinkValue.hidden = true


if (resolutionValue == "10002" && actionName == screenName) {
issueLinkType.hidden = false
issueLinkValue.hidden = false
}

Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.

So in this example, when the dialog first appears, the Linked Issues option will be hidden.  Only when the Resolution list is updated to Duplicate will the Linked Issues option be visible.

Below is a print screen of the Behaviour configuration that I have tested with:-

behaviour_config.png

I hope this helps to solve your question :)

 

Thank you and Kind Regards,

Ram

THANK YOU!  This is a great answer, I really appreciate the suggestion to use browser dev tools to get the correct names.

One further note for anyone looking at this solution: it's responding to the name of the workflow button/display name of the screen, not the name of the screen in the screen configuration.

In my case, the name of the screen in the screen configuration is "Resolution and Assignee" but the display name that should be used in the script is "To Solved".

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...

95 views 0 5
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