Hello Community
I am stuck with a scenario. Please help me. I have a custom field type : Label in my issuetype Epic. Name of Label (customefield is) : Additional IDs.
Scenario
User is expected to enter minimum 1 and maximum 10 Ids into the field and each entered Id must be 8 Characters long only. If user enters more than 10 Ids, an error should be shown on the screen. If user enter an Id which is not equal to 8 characters should throw an error on the screen as user updates epic.
I have Scriptrunner installed on my jira server edition.
Please advice me how to implement this constraints on the field.
Thank you .
Anupam
You can add a Validator of type Simple scripted validator [ScriptRunner] with a Condition like this:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.CustomField
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
CustomField myCustomField = customFieldManager.getCustomFieldObjectsByName("Your Custom Field Name")[0]
boolean allValidLength = true
int numLabels = 0
issue.getCustomFieldValue(myCustomField).each{
numLabels++
if(it.toString().size() != 8){
allValidLength = false
}
}
return numLabels <= 10 && allValidLength
And an Error Message like: Each Additional ID must be 8 characters in length, and there must not be more than 10 of them.
Thanks for replying and help @Payne
I am not sure at which status I should add this validator. I have large workflow with more than 10 statuses. User wants check should be in place at screen and irrespective of status of Epic.
Thanks,
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In a situation like this we have put a validator near the beginning of the workflow when the issue is created and one more near closure. Think about when the user will provide those IDs and go from there.
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.