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

Thanks Rambanam.

don't forgot accept as a answer :)

This widget could not be displayed.

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

@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
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

203 views 1 3
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