“Capacity” field should be an integer value between 1 and 100 inclusive. I’d like to validate that value and throw an error message if outside that range, typically validation done upon hitting “Create”.
Do you have any apps, such as ScriptRunner? Without one of those, I don't know if you can accomplish this.
In that case, one way to accomplish your goal is to create a "Simple Scripted Validator" with a Condition like this:
def capacityField = customFieldManager.getCustomFieldObjectsByName("Capacity")[0]
def capacityValue = issue.getCustomFieldValue(capacityField)
return capacityValue == null || ((int)capacityValue >= 1 && (int)capacityValue <= 100)
And an error message like this:
Capacity should have a value between 1 and 100, inclusive.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm sorry but ScriptRunner is completely new for me...
I don't know how It'll show an error.
Will you please add complete code with an error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have written this code in behavior for capacity field.
but It shows an error the variable issue is undeclared.
plz correct code ....
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cfValues = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Capacity")
def cValue = issue.getCustomFieldValue(cfValues)
if ((int)cValue < 1 || (int)cValue > 100) {
throw new InvalidInputException("Capacity field should be an integer value between 1 and 100 ")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For a "Simple Scripted Validator", there is a field where you type the error text that you wish to display on a failure.
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.