It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to Hide Attachment(system field) using behavior script in JIRA

Hi Team,

I am trying to Hide System Field(Attachment) using getFieldbyName("Attachment") but it is not working. While the same working for custom fields only not for System field. Please suggest.

Script below 

 

def What_type_of_access_request = getFieldById("customfield_32750")
def First_Name = getFieldById("customfield_32751")
def Last_Name = getFieldById("customfield_32752")
def Location = getFieldById("customfield_32753")
def Email_Address = getFieldById("customfield_32754")
def NW_Login_ID = getFieldById("customfield_32755")
def Employee_ID = getFieldById("customfield_32756")
def User_Supervisor_Name = getFieldById("customfield_32757")
def User_Supervisor_NW_ID = getFieldById("customfield_32758")
def User_Supervisor_manager = getFieldById("customfield_32759")
def NICE_Extn = getFieldById("customfield_32760")
def Attachment = getFieldByName("Attachment")
def verticalValue = What_type_of_access_request.getValue() as String
log.debug "Selected option: $verticalValue"

if (verticalValue== "Single User")
{
First_Name.setHidden(false);
Last_Name.setHidden(false);
Location.setHidden(false);
Email_Address.setHidden(false);
NW_Login_ID.setHidden(false);
Employee_ID.setHidden(false);
User_Supervisor_Name.setHidden(false);
User_Supervisor_NW_ID.setHidden(false);
User_Supervisor_manager.setHidden(false);
NICE_Extn.setHidden(false);
Attachment.setHidden(true);
}

else
{
First_Name.setHidden(true);
Last_Name.setHidden(true);
Location.setHidden(true);
Email_Address.setHidden(true);
NW_Login_ID.setHidden(true);
Employee_ID.setHidden(true);
User_Supervisor_Name.setHidden(true);
User_Supervisor_NW_ID.setHidden(true);
User_Supervisor_manager.setHidden(true);
NICE_Extn.setHidden(true);
Attachment.setHidden(false);
}

 

1 answer

Hello, looks like attachements isn't really a Jira field like the others:

https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-apply-behaviors-Behaviours-Plugin-to-attachment-field-in/qaq-p/486044

so behaviours can't affect it

Hi Ilya,

 

I have fixed this issue.

We can't use system field byname, we can use system field by ID only

 

Attachment id is "attachment".

 

def Attachment = getFieldById("attachment")

 

Thanks

Like Ilya Turov likes this

hmh, i tried something similar myself, didnt get it to work, googled and found info above

guess its outdated, now that i tested it - it really works

good for you

hmm... I was also searching on google but not get proper solution.

I asked Adaptivsit team for the solution, they suggest me to use in this way. 

I tested and it worked for me as well. Custom field works ByName but system field works onlys with ID.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you