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

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

don't forgot accept as a answer :)

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

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,847 views 12 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot