Forums

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

Hiding custom fields based on assignee

Deepti Hasija August 17, 2021

Hi,

I am trying to hide 4 fields ( project lead, design author, contributor and consultant) from the project based on assignee using  behaviors in JIRA

I added field under behavior as "Assignee"  as optional, writable and shown and then wrote this server-side script

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser

def assignee = getFieldById("assignee")
def ProjectLead = getFieldById("customField_21153")
def DesignAuthor = getFieldById("customField_21154")
def Contributors = getFieldById("customField_21155")
def Consultants = getFieldById("customField_21156")

log.debug("Assignee " + assignee.getValue())

if (assignee.getValue() == "backlog-server-storage-engines") {
ProjectLead.setHidden(false);
DesignAuthor.setHidden(false);
Contributors.setHidden(false);
Consultants.setHidden(false);
}
else
{
ProjectLead.setHidden(true);
DesignAuthor.setHidden(true);
Contributors.setHidden(true);
Consultants.setHidden(true);
}

 

This is not working, can someone suggest what am i doing wrong? Thanks

 

2 answers

1 vote
Nic Brough -Adaptavist-
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.
August 17, 2021

I don't think it's your "set" code - https://library.adaptavist.com/entity/set-behaviour-hidden is the example I start from when wanting to hide fields

I suspect it's the "if" - I don't think the assignee value == "your string" - assignee should really be giving you a user, not a string.

Deepti Hasija August 19, 2021

Hi Nic,

Thanks for replying.

How can i check the assignee value in behaviors then if not using ==?

 

Another thing is, i want this behaviour to check for assignee value in real-time  during issue create i.e hide the 4 fields if the assignee is changes from unassigned to "backlog-server-storage-engines" . I am not sure if this will work via behaviour or i need to add a post function?

0 votes
Ignacio Pulgar
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.
August 17, 2021

By the way, is this really for Cloud? I thought Behaviours was available just on Server/DC instances.

Nic Brough -Adaptavist-
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.
August 17, 2021

Good point, it can't be for Cloud, Cloud doesn't support Behaviours yet.  I've removed the misleading tags.

Like Ignacio Pulgar likes this
Ignacio Pulgar
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.
August 17, 2021

Thanks! :)

Suggest an answer

Log in or Sign up to answer