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.
Any help?
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"
I"m new to all this and am starting to follow your lead and understand it. So, i will start investigating the APIs more to which one will allow me to do that.
How would I handle the issue creation? Since that's not really a transition ?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is what I needed. Thanks to Nic for pointing me to the right direction.
Making fields option/required:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi John. Were you able to code for required in field configurations? If yes, could you guide me with the solution. I have been searching online and in the API for days now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.