Dear community,
I am trying to configer a behavior in the way that "Additional Information" field is hidden if the issue type is not "Serives Incomplete" and set "Additional Information" field as required if issue type is "Serives Incomplete".
The issue type is present in a transition pop-up together with the Additional information field but it doesn't seem to work. My code in behaviors is as follows:
But if I change it to :
The approach you are trying will not work as expected.
Since you want to make the change based on the issue type, you must use the Behaviour Initialiser instead of the Server-Side Behaviour.
Below is a sample working code for your reference:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def sampleTextField = getFieldByName('Sample Text Field')
sampleTextField.hidden = true
sampleTextField.required = false
if(issueContext.issueType.name in ['Bug', 'Story']) {
sampleTextField.hidden = false
sampleTextField.required = true
}
Please note that the sample working code above is not 100% exact to your environment. Hence, you must make the required modifications.
Below is a screenshot of the Behaviour configuration:-
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram,
Thank you for your reply.
If I set it to :
Looks like it only looks into the line with 'True' in it and doesn't check what type of issue it is (there are 3 possible Issue types:
Supplies,
Services
Services Incomplete
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There appears to be an error in your code.
If you look at this line:-
if(issueContext.issueType.name in ['Services'. 'Supplies']) {
sampleTextField.hidden = true
sampleTextField.required = false
}
You should not use a dot to separate the options. Also, there is no point in setting the hidden to true and required to false since it is already set to that by default
Instead, you must use a comma like this:-
if(!(issueContext.issueType.name in ['Services', 'Supplies'])) {
sampleTextField.hidden = false
sampleTextField.required = true
}
Please make the correction and try to test it again.
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram,
Sorry, it was a typo.
With comma - same result.
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure why it's not working in your environment, because it's working just fine on mine.
Please replace your code with just the logging parameter below and see what is returned when you select the particular issue type.
log.warn "===============>>>>> Issue Type: ${issueContext.issueType.name}"
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Irya,
Please share the log output so I can see what is happening.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.