My company is evaluating either to use Script Runner or not. One of our requirement is to only allow a certain issue created when Task, New Feature, or Improvement issue types is selected and a value (Capital) of one of the our custom field. Also, if the user selects other values of the custom field would allow to create the issue regardless of the issue type.
Scenario:
If there are other options to do this, let me know.
Thanks
Hi Rex,
I can confirm that a Simple Scripted Validator provided by the Script Runner plugin could be placed on the create transition of the issue in order to solve your requirements outlined below.
The way the validator would work would be to check to see if the Issue type was Bug and if so it would check if the Capital value had not been selected in the drop down list and only allow the issue to be created if this was the case. If the Capital value was selected when the issue type was of Bug then it would show an error to the user as shown in the screenshots below otherwise it would allow the issue to be created.
I have attached the code below along with some screenshots of how this works and should be configured below.
Code:
if (issue.issueTypeObject.name == 'Bug' && cfValues['DemoSelectList']?.value == 'Capital'){ return false }else { return true }
Config:
image2016-3-10 17:17:16.png
Result:
image2016-3-10 17:17:25.png
Kristian
Conditioned validator from Update on Transition for JIRA uses regular expression based condition checking that can usually accommodate requirements like these.
Thanks,
We will consider this add-on.
Thanks Kristian,
The code works.
Glad I was able to help.
Kristian,
Can this functionality be done in the update screen? I understand it will not be a validator. Can it be a behaviours or other functionality in Script Runner?
Rex
Yes you would need to use Behaviours to implement similar functionality on the edit issue screen.
An example of how you could achieve this is shown below.
// Required Imports import com.atlassian.jira.component.ComponentAccessor // Get a pointer to my select list field def selectList = getFieldByName("DemoSelectList") // Get the Value of the Demo Select List Field def selectListVal = selectList.getValue() // If the Value is Capital throw and error if(selectListVal == "Capital"){ selectList.setError("The Capital Value can only be used for the Task, New Feature and Improvement Issue Types") }
Mapping required to only fire for Bug Issue Type:
image2016-3-21 16:28:51.png
image2016-3-21 16:29:21.png
image2016-3-21 16:30:49.png
I hope this helps
It's working in the create screen, how do you add it to the edit screen.
Behaviours work on the create and edit screens by default but do not work when a field is inline edited.
The behaviour is able to work without the validator in the create screen.
Here is a scenario:
image2016-3-22 7:29:39.png
2. Edit the issue first time with the issue type of bug:
image2016-3-22 7:31:16.png
3. Issue lets it changed (behaviour didn't work)
image2016-3-22 7:32:7.png
4. Edit the issue the second time: (it has the error, but I am not able to update to another issue type or even charge type)
image2016-3-22 7:33:32.png
image2016-3-22 7:35:13.png
What do you think?
It looks like you're new here. Sign in or register to get started.