Hi,
I have looked around and have create a hide field and revel when something is chosen eg. When resolution is duplicate, the duplicate link will be revelled and set to mandatory.
What I want to do now is to do it on the workflow at the post function. Is this possible?
My code so far is
def issueManager = ComponentAccessor.getIssueManager()
def constantsManager = ComponentAccessor.getConstantsManager()
def resolution = constantsManager.resolutions.findByName("Resolved")
def fixVersion= issue.getFixVersions()
if ( resolution == "Resolved" )
{
fixVersion.setRequired(true)
fixVersion.setHidden(false)
}
else {
fixVersion.setRequired(false)
fixVersion.setHidden(true)
}
The errors I'm getting is attached. Meanwhile I'll still look for an answer.
( I'm assuming is that my fixVersion is getting the value instead of the field? )
Hello @Johnathan Teo
The code samples you have in the screenshot and the ability to hide/show fields and the API you have used are part of the "Behaviour" module of the Script runner plugin and not the post-function, using this in post-funciton will not work.
https://scriptrunner.adaptavist.com/5.4.47/jira/behaviours-overview.html
Here's where you can have the behaviour available for customizations
https://scriptrunner.adaptavist.com/5.4.47/jira/behaviours-overview.html#_screens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, I see. Is there a way to actually do it in post function instead of in behaviours ?
As there is another condition that the status must be moving to closed before this will trigger.
As there are many links made to close, it is hard for me to check by status. So I was thinking of putting the code on the transition when it moves to close.
So what will happen is when a user transition to close, there is a pop up screen asking them to choose their resolution. When they choose "Resolved" the Fix Version field should pop up and be made mandatory.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Johnathan Teo
Having the code in the post-function is not possible but it's best to have it as part of the transition screen. So that resolution is not set you can set "error" on the fixVersion and when resolution is set you can then "clearError" using setError method from API will prevent the user from submitting the transition screen and hence no need to extra validation as well.
If my answer, helped you then please accept/upvote the answer so that other users are also helped. thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.