I have two questions Please!
1. I normally use ScriptRunner defaults scripts, but I need to make a field required based on a specific summary. I have tried the following script but it's not working. When transitioning to Done, set the "New ToLID" custom field if the issue summary field is as follows: "New ToLID assigned. The issue is a subtask. I am setting this in the Behaviours. Pls advise
if ("Done".equals(getActionName())) {
log.error("Behaviour start on screen Done issue")
def targetField = getFieldByName("New ToLID")
targetField.setRequired(false)
if (issue.getSummary().contains("New ToLID assigned"))
targetField.setRequired(true)
}
}
2. I tried to use the ScriptRunner Validator field required in the workflow, but when i get to the select field option it has no option see screenshot below, even those there are a bunch of custiom fields configured on the data center server. On the other hand, i can see the custome fields when using conditions, but when set it makes the transition button disappear. Please advise. Many Thanks in Advance
Hi @Tanwa Arewa
For your requirement, you don't need to invoke the underlyingIssue in the Behaviour. You can do this:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def summary = getFieldById(fieldChanged)
def sampleField = getFieldByName('Sample Field')
sampleField.required = false
if(summary.toString().contains('Sample Field') && actionName == 'Done') {
sampleField.required = true
}
Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.
When the issue transitions to Done and the transition screen appears, the Sample Field text field will be mandatory if the Summary has the value Sample Field in it.
Below are a few test print screens for your reference:-
1) The summary currently is just Test
2) When the issue transition's to Done, the Sample Field is not set to mandatory.
3) Once the field name, i.e. Sample Field, is included, the Sample Field text field is mandatory.
4) Now, if you try to click on the Done button without entering any values into the Sample Field, an Error message is returned, as displayed below.
I hope this helps to answer your question. :)
Thank you and Kind Regards,
Ram
Thank You so much @Ram Kumar Aravindakshan _Adaptavist_ for the prompt solution. I have used the code and it works perfectly. Very Much Appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tanwa Arewa,
If I understood correctly you want to limit the behaviour done transition
how about below code. this can be a initializer script
if(fieldScreen.name == "Transition screen name"){
if(issue.summary.contains("required string")){
getFieldByName("Field Name").setRequired(true)
}
}
BR,
Leo
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.
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.