Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Issue Picker Field is not working when set to Required by Behavior during issue transition.

sanjay
Contributor
July 7, 2020

def DJ = getFieldById("customfield_10702")
def TC = getFieldById("customfield_10809")
def TJ = getFieldById("customfield_10703")
def CR = getFieldById("customfield_10700")
def DI = getFieldById("customfield_10500")

if (s == "Duplicate defect" )

{


  TC.setHidden(true)
  DJ.setHidden(true)
  TJ.setHidden(true)
  CR.setHidden(true)
  DI.setHidden(false)
  DJ.setRequired(false)
  CR.setRequired(false)
  TC.setRequired(false)
  TJ.setRequired(false)
  DI.setRequired(true)


}

Here is the condition I am checking but getting Error "Please enter the value for the field"

Even if I choose the issue and test the field showing above mentioned error.

Please help in the scenario.

 

 

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Adrien Low _ServiceRocket_
Community Champion
December 24, 2021

Hey @Amelia Zaccara ,

Adding on to what @Mohamed Benziane has suggested.

As Behaviors will run in both the Create and Edit screen, this may cause some issues for you as the Summary field is a required field while creating an issue.

You can also add another condition to check if you're in the create screen.

An example below:-

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)

def summary = getFieldById('summary')
def adminRole = projectRoleManager.getProjectRole('Administrators')
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def currentProject = getIssueContext().getProjectObject()

//Set Summary field as ReadOnly only if not in the Create screen
if(getAction() != 'Create') {

summary.setReadOnly(true)

//Check for user role here
if(projectRoleManager.isUserInProjectRole(currentUser, adminRole, currentProject)) {
summary.setReadOnly(false)
}

}

Regards.

Amelia Zaccara
December 27, 2021

Hi @Adrien Low _ServiceRocket_ and @Mohamed Benziane
thanks for the advice.
I will add the condition in the behaviours.
Will it be necessary to create an additional line: 

def adminRole = projectRoleManager.getProjectRole('Administrators')

for each project role that is allowed to edit the summary in the issue?

 

Thank you!

Amelia

0 votes
Mohamed Benziane
Community Champion
November 3, 2021

Hi @Amelia Zaccara 

Welcome to the community.

Yes this is possible with behaviour. You just need to make the summary fiel read only and add a new condition "except user in project role"

TAGS
AUG Leaders

Atlassian Community Events