You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
As i used validation on component (to select/restrict to one field only )
------------------------------------------------------------------------------
1st i tried this
import com.onresolve.jira.groovy.user.FieldBehaviours
import org.apache.log4j.Logger
import org.apache.log4j.Level
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.project.component.ProjectComponent
def component = getFieldById('components-textarea')
List <ProjectComponent> result = component.getFormValue() as List
if(result.size() >1)
{
component .setError("Only one Component is allowed")
}
else {
component.clearError()
}
------------------------------------------------------------------------------
2 ] I tried to get atleast size of selected element
def c = ComponentAccessor.componentClassManager.getMetaPropertyValues()
def component = getFieldById('components-textarea')
component.setHelpText("----->>Multi Select Field is set to Support " + c.size())
------------------------------------------------------------------------------
Help me to put validation on component field . My Requirement is to select only one field from System component field .
Hi @Nishant Paraskar ,
you are using incorrect id for components field, it should be "components" instead of "components-textarea".
Something like this should work:
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.onresolve.jira.groovy.user.FormField
import static com.atlassian.jira.issue.IssueFieldConstants.COMPONENTS
FormField componentsField = getFieldById(COMPONENTS)
List<ProjectComponent> components = componentsField.getValue() as List
if (components.size() > 1) {
componentsField.setError("Only one Component is allowed")
} else {
componentsField.clearError()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
test
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.