Jira Version : 8.8.1
Scriptrunner Version : 6.37.0
I am trying to create a behavior within a transition where when users select a specific value in Resolution field it will hide the listed required fields and remove requirement.
However I the scripts I tried will only trigger upon loading of the transition screen.
Once I selected the expected values ie. Duplicate or Request Cancelled it does not update anymore.
I tried the following scripts.
~~Current saved script
def CField1= getFieldByName("Requestor Region")
def CField2= getFieldByName("Platform")
def TCType = getFieldByName("Resolution")
def selectedOption = TCType.getValue() as String
if(selectedOption=="Duplicate")
{
CField1.setHidden(true)
CField2.setHidden(true)
CField1.setRequired(false)
CField2.setRequired(false)
}
else if (selectedOption=="Request Cancelled")
{
CField1.setHidden(true)
CField2.setHidden(true)
CField1.setRequired(false)
CField2.setRequired(false)
}
else if (selectedOption!="Request Cancelled" || selectedOption!="Duplicate")
{
CField1.setHidden(false)
CField2.setHidden(false)
CField1.setRequired(true)
CField2.setRequired(true)
}
~~~Other scripts tried
Script 1 :
if (getActionName().equals("Setup Complete")) {
boolean hidden = (getFieldByName("Resolution")?.getValue()?.toString()?.equals("Duplicate"));
getFieldByName("Platform").setHidden(hidden);
}
Script 2:
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def platform = getFieldById('customfield_14524') //Platform
def components = getFieldById(getFieldChanged()).getValue() as List<ProjectComponent>
def compField = getFieldByName("Resolution")
compField.setAllowInlineEdit(false)
if (components.any {it.name.contains("Duplicate")}) {
platform.setHidden(false)
platform.setRequired(true)
}
else {
platform.setHidden(true)
platform.setRequired(false)
}
I have properly mapped the script since I am able to hide fields upon load upon testing.
I also tried via the initialiser function, nothing updates either.
Is there anything else I need to configure or something missing on my script?
Here are troubleshooting methods you can follow
Thanks,
Pramodh
Hi @Pramodh M
I tried switching with getFieldById, looks like I am getting null on this part(I got this via developer tools)
def selectedOption = TCType.getValue() as String
As for the logging output, I am having a hard time tracking error log.
I already enabled logging via com.onresolve.jira.groovy (DEBUG) but no entries were made when I went to the log file.
Is there another way to debug the script, like could I make a message prompt like in javascript, or somehow print a message in developer tools console?
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.