Hello team,
I have added one validation for one field while creating the Issue (issue type = Bug).
if ((issue.issueTypeObject.name == 'Bug') && !cfValues['Regression Bug']) {
return false;
} else {
if (cfValues['Regression Bug']?.value == 'Could not be checked' && !cfValues['Regression Bug Comment']) {
return false;
}
return true;
}
Now for one another field I need to check the user is developer and field value is "NOT SET" otherwise return false.
I will add this code in simple scripted validator.
Please help me with this.
Thanks
Suhas
Hello Suhas,
To find the project role you can use the following:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.security.roles.ProjectRoleManager
def projectManager = ComponentAccessor.projectManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def allProjects = projectManager.getProjects()
def project = allProjects.find(){it.getName() == "Project Name"}
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def projectRoles = projectRoleManager.getProjectRoles(user, project)
def memberOf = projectRoles.find(){it.getName() == "Developer"}?true:false
if (memberOf){
*Do stuff*
}
I am not sure what you mean with field value is not set. Is it a select field with the option "NOT SET" or is it null?
Yes, its a field with value "NOT SET".
So you saying the above code will work in simple scripted validator?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raskou
I have achieved this using following:
if ((isUserMemberOfRole('Developers')) && cfValues['Management Flag']!= 'NOT SET') {
return false;
}
return true;
Thanks for your help!
Regards,
Suhas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Suhas,
That's great, glad you got it working!
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.