Forums

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

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

Vikrant Yadav
Community Champion
November 13, 2019

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

0 votes
Ilya Turov
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.
November 13, 2019

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

Vikrant Yadav
Community Champion
November 15, 2019

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
Ilya Turov
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.
November 15, 2019

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

Vikrant Yadav
Community Champion
November 15, 2019

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.

Nagaraju Tella
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!
January 29, 2025

Thanks @Vikrant Yadav 

ID is working.

Suggest an answer

Log in or Sign up to answer