Forums

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

How to hide Priority field on custom field value selection?

mani@123
Contributor
July 6, 2019

Hello All,

I have hided custom fields on selection of other custom field value section with the below script in behavior.

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def myrequestclassField = getFieldById(getFieldChanged())
def valueField = getFieldByName("Branding")

String myrequestclassValue = myrequestclassField.getValue()

if (myrequestclassValue == "Folder Structure and File Move Request") {
valueField.setHidden(true)
} else {
valueField.setHidden(false)
}

But this is not working for Priority field(system field). 

can any one please help.

Thanks,

Mani

 

1 answer

0 votes
PD Sheehan
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 Leaders.
July 8, 2019

For priority and other system fields, you'll want to use:

getCustomFieldById('priority')

Or, you can use the IssueFieldConstants class if you want to use autocomplete:

import com.atlassian.jira.issue.IssueFieldConstants
getCustomFieldById(IssueFieldConstants.PRIORITY)
mani@123
Contributor
July 8, 2019

Hi Peter,

Thanks for your help!

I have tried above solution, but no luck. Could you please check my below script??

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def myrequestclassField = getCustomFieldById(getFieldChanged())
def valueField = getCustomFieldById('priority')

String myrequestclassValue = myrequestclassField.getValue()

if (myrequestclassValue == "Folder Structure and File Move Request") {
valueField.setHidden(true)
} else {
valueField.setHidden(false)
}

Error - "Cannot find matching method"

 

Thanks again,

Mani

PD Sheehan
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 Leaders.
July 8, 2019

Sorry, bad cut and paste on my part. 

It should be 

def priorityField = getFileById(‘priority’)
def priorityVal = priorityField.value

I don’t recall what type of value you will get from this. It may just be the priority id. And then you may have to get the value from somewhere else. Or else find the I’d for your priority and compare against that. 

Suggest an answer

Log in or Sign up to answer