How can I programatically make a custom field that I created (also programatically) required on a given field conifguration screen?
I have looked through the docs and found a few methods that return a boolean if the field is required, but none to set the field as required.
It's a common request with an easy fix, but it's nothing to do with screens or field configurations.
A screen simply says "this field shows when I am used for create/edit/view/transition". It has nothing to say about mandatory fields
A field configuration is totally different. It's got nothing to say about what fields are on a screen, but does tell Jira if a field is a) available to the project/issuetype and b) mandatory through the whole life-cycle.
The "fix" is simply to use a "validator" on transitions to say "field must be filled in on this transition"
Issue create is a transition, just an odd one (no conditions, and no start point). You can add validators to create.
Also, you can make a field required in the field configurations and Jira will require it on issue-create (you just won't be able to blank it out anywhere in the issue lifecycle)
Thanks Nic. That wont give me the asterix on the screen to notify the user that the field is required until it's posted correct?
I'm also interested in that. Just how you would mark the field required manually through the field config screen as admin, just programatically since these will be created upon plugin installation.
A validator will not give you the asterix. The field configuration will.
To do it in the UI, go to admin -> field configurations -> Field configuration, find the field you want to make mandatory and click the mandatory flag. For each one.
Programatically, er, well, don't. You almost certainly don't want to make a custom field mandatory when you install a plugin. Someone who installs such a plugin is going to end up with users screaming that it's unusable, because it'll mess up all their configurations.
If you must do this, then your code *must* do the following:
Seriously, I REALLY wouldn't do this. I certainly wouldn't use a plugin that does it. (Heck, I'd avoid creating custom fields automatically on plugin install). Keep your code simple - *provide* new field types, and document how to add and use them. It only takes an admin a few clicks to add a new field and using their knowledge of their system to require the fields where they're actually needed instead of vandalising the whole thing is what your admins are there for.
This whole thing will be in isolation to everything within JIRA.
I'm stuck on # 2 on how to set my custom fields (on my own custom screens and issue types and etc ...) as "required" or "mandatory" to get the asterix to indicate the user that the field is required before they even click "submit/create".
I can't find the method call similiar to "setRequired" or "setMandatory" in any of the classes. Which class and what method would I utilize for this operation? I'm past the point of creating the custom field and the field configuration and tied them together. I just need to mark the fields as required now.
I'm using EditableFieldLayoutImpl to create my Field Configuration and right after I can loop through and getall the FieldLayoutItem. Not sure how close or far I'm from achieving what I want.
BTW: thanks for all the feedback and the approach. It's still early and I'm experimenting with this.
This is what I needed. Thanks to Nic for pointing me to the right direction.
Making fields option/required:
Hi all Lets make this Friday fun really fun and post one (or more) of your best jokes! The joke can be about an Atlassian product, or just a really fun joke you want to share! I’m not the best j...
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!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot