how to check if a custom field on a screen is hidden

Umair Haroon
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.
March 11, 2014

Hi,

whenever there is a transition (eg from submitted to assign) I run a script.

In the scrip I am able to get a custom field by doing :

CustomField customField_name = customFieldManager.getCustomFieldObjectByName( "Create Job" );

Where "Create Job" is a custom field I created.

I want to ask how can I check if the field was hidden?

The script I run is not client side but a groovy script on the server.

I know its probably a simple API call but I dont know which one it is.

So if anyone can answer quickly that would be cool :D

Else I will go to the API docs! :D

Thanks

Regards

2 answers

1 accepted

1 vote
Answer accepted
RambanamP
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.
March 11, 2014
Umair Haroon
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.
March 19, 2014

Thanks Rambanam.

RambanamP
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.
March 19, 2014

don't forgot accept as a answer :)

2 votes
Sergey Temchenko
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.
May 13, 2016

In order not to create new topic i will describe my solution here, besides this topic has been indexed by Google, so maybe it will be useful for someone.

I've just run into same problem, but this solutions wasn't suitable for me. So i started researching JIRA API.

In example above, i should know about 3 params to check whether field on the screen or not.

public boolean isFieldOnScreen(Issue issue, Field field, FieldScreen fieldScreen)
{
}

But in my case i have only 1 param - Issue, and i don't know what FieldScreen is.

So here is my solution, from Condition class, and it checks Story Points field

public boolean shouldDisplay(ApplicationUser user, JiraHelper jiraHelper)
{
   Map params = jiraHelper.getContextParams();
   Issue issue = (Issue)params.get("issue");
   boolean isFieldOnScreen = false;
   CustomField storyPointsField = this.customFieldManager.getCustomFieldObjectByName("Story Points");

   /**
    * Get suitable field screen scheme for existed issue, it will find correct association either
    * Default - Screen Scheme
    * or
    * [Issue Type] - Screen Scheme
    */
   FieldScreenScheme fss = this.issueTypeScreenSchemeManager.getFieldScreenScheme(issue);

   /**
    * Iterate over all available operations within scheme
    * -Create
    * -Edit
    * -View
    */
   for (FieldScreenSchemeItem fssi : fss.getFieldScreenSchemeItems()) {

      //Get field screen for current operation
      FieldScreen fs = fss.getFieldScreen(fssi.getIssueOperation());

      //Iterate over all tabs on screen
      for (FieldScreenTab fst : fs.getTabs()) {

         //Check whether tab has field or no
         if (fst.isContainsField(storyPointsField.getId())) {

            isFieldOnScreen = true;
            break;

         }

      }

   }

   return isFieldOnScreen;
}

Check this out.

Also, you can get IssueTypeScreenScheme, for specified project

IssueTypeScreenScheme getIssueTypeScreenScheme(Project project);
IssueTypeScreenScheme getIssueTypeScreenScheme(Long id);

And then, get

FieldScreenScheme
getEffectiveFieldScreenScheme(IssueType type);

by your issuetype, from issue or check something different on this scheme.

Hope, this'll help smile

Yves Riel [Okapya]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 29, 2018

@Sergey Temchenko, a big thanks for posting this out! Saved me a lot of energy browsing Jira's API and figuring it out by mylself. I was on a tight deadline :-)

Suggest an answer

Log in or Sign up to answer