Forums

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

condition to hide an UI element

Aswin Sudharsan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 31, 2019

Greetings,

I am trying to hide a UI from our board u could see below. I am trying to remove add users to role and edit defaults. 

We have the script runner 5.6.9.1p5. I have found out which element to hide but it's not accepting any of the conditions.

Can anyone help me regarding the condition in hiding this element?

Capture121.PNG

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Marco Brundel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
November 12, 2018

Adaptavist told me the following:

 

To achieve what you are asking you need to use a behaviour instead of a validation.

Can you try this code as a server side script for a behaviour on the "Application Area" field:

 

def ApplicationAreaField = getFieldByName("Application Area")
def CompanyandRoleField = getFieldByName("Company and Role")

ArrayList ApplicationAreaValue = ApplicationAreaField.getValue() as ArrayList

if (ApplicationAreaValue.contains("SL SAP ECC")){ 
CompanyandRoleField.setRequired(true)
} else{ 
CompanyandRoleField.setRequired(false) 
}

 And this works for my situation

0 votes
Neta Elyakim
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
November 11, 2018

Do you use script behavior or script validator? According to your syntax, it seems like you are using behavior.

If you are using script validator, use this script:

Note that you need to change the id in applicationAreaValue and companyRoleFieldValue params.

import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException

def customFieldManager = ComponentAccessor.getCustomFieldManager()

String applicationAreaValue = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject(11111 as long))//Change the id to 'Application Area' field id
String companyRoleFieldValue = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject(11111 as long))//Change the id to 'Company and Role' field id

if (applicationAreaValue == "SL SAP ECC") {
if (companyRoleFieldValue == null) {
invalidInputException = new InvalidInputException("'Company and Role' is mandatory when 'Application Area' is SL SAP ECC")
return null
}
}
TAGS
AUG Leaders

Atlassian Community Events