Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Hide customfield with Script Runner / Behaviours

Hans-Hermann Hunfeld September 18, 2015

Tried to hide a numeric custom field with the Script Runner behaviour addon:

2015-09-18 14_29_16-Behaviours - JIRA.jpg

The script is:

FormField fieldFF = getFieldById("customfield_14401")
{
      fieldFF.setHidden(true);
}

Although i added the mapping to the correct projet this is not working, any ideas what is wrong here?

Thanks & regards,

Hans-Hermann

5 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Rodrigo Nunes October 22, 2018

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.ComponentManager
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.*

@BaseScript FieldBehaviours fieldBehaviours

def A= getFieldById("customfield_10109")
def B = getFieldById("customfield_10120")
def C = getFieldById("customfield_10018")
def D = getFieldById("customfield_10019")
def E = getFieldById("customfield_10201")
def F = getFieldById("customfield_10124")

if (A.getValue() == "aaaaa"){
B.setHidden(false);
C.setHidden(false);
D.setHidden(false);
E.setHidden(false);
}
else {
B.setHidden(true);
C.setHidden(true);
D.setHidden(true);
E.setHidden(true);
}

Faiza Kazmi April 23, 2019

can you please provide the code of how can i hide the field upon a user/group or role.

Like Vitalii Abrosimov likes this
0 votes
Hans-Hermann Hunfeld September 20, 2015

Hi there,

a full reindex during the weekend didn´t change anything, so still very interested in getting this up&running... wink

Best regards,
Hans-Hermann

0 votes
Hans-Hermann Hunfeld September 18, 2015

Hi,

i tested it several times and checked Ids etc, but no success:

2015-09-18 15_10_24-Custom Fields - JIRA.jpg2015-09-18 15_10_55-[SBX-998] Test Update Attachement from Confluence - JIRA.jpg2015-09-18 15_12_10-Behaviours - JIRA.jpg

Also tried

FormField fieldFF = getFieldById("customfield_14401")
fieldFF.setHidden(true);

but without any changes.

@Jamie Echlin [Adaptavist]: Tried both being assignee and unassigned, but no change. Please mind the error message that the field cannot be hidden based on the UI settings due to your documentation as it´s from type "Number"...

JamieA
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.
September 18, 2015

It's only hidden in the edit screens. The exceptions are the two "hideable" fields that are implemented, which are just short and long string. That's what the message is telling you. I can add an RFE to add other types of hideable field. But you can possibly remove it from the View Issue screen.

Hans-Hermann Hunfeld September 18, 2015

Hmm, currently the field is also shown on the edit fields unregarding who is the assignee...?! Removing from View Screen is no option as some user groups should see this field and others not. Beside an paid addon i didn´t find any option to realize this feature, hope i could do that (as many other stuff) with your plugin...

0 votes
Tomasz Stec
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.
September 18, 2015

Hi,

I am guessing that the syntax of your behavoiurs script is incorrect. I don't know what actually were you trying to do, use na open code block or an annonymus closure, but for such simple script you don't need it so try:

FormField fieldFF = getFieldById("customfield_14401")
fieldFF.setHidden(true);

if you necessarily need an closure then use it right: declare AND invoke, for instance:

FormField fieldFF = getFieldById("customfield_14401")
{it->
      fieldFF.setHidden(true);
}.call()

or using open code block label it:

FormField fieldFF = getFieldById("customfield_14401")
L:{
	fieldFF.setHidden(true);
}
0 votes
JamieA
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.
September 18, 2015

Not sure why it's in a block... you have clicked Hidden in the UI, so it should be hidden when the current user is the assignee. You don't need any script here.

Is it hidden in the UI?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events