Hello Community People,
I have a project created in our JIRA environment which has around 15 Issue Types. I have two custom fields which I want to make mandatory & visible only on one of the Issue Type. Can someone help with it ?
I have tried it with Behaviour Settings but it's not working.
Hi @Vishal
You can set a field required by adding a field configuration and a field configuration scheme. It's the same as with mapping workflows to issue types. You create the field configuration where you mark your specific fields as required, and in the field configuration scheme, you map it to an issue type.
Afterwards, associate the scheme to the project. More info here: https://confluence.atlassian.com/adminjiraserver/specifying-field-behavior-938847255.html
Kind regards
Jorden
Hello Jorden,
Sorry I missed this in question itself, actually I have done the same in in field configuration but it's making it require for all the issue type, which I don't want.
I want it to be require for only one issue type & rest all to be hidden & not required.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vishal
Have you perhaps made it required in the default field configuration? This will apply to everything that doesn't have a specific association.
Make sure you have a brand new field configuration and field configuration scheme when making a field mandatory.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I had made default field configuration as required as I didn't want to create more field configuration screen.
I am looking for something like all the issue type should use same screen scheme but using behaviour or something make only those two fields to be available for the one issue type only & remain hidden & not required for rest all.
I am trying to run below server side script using behavior for all the issue type in that project except the one where I want it to be present but it's not working.
def customfield= getFieldById ("customfield_xxxxx")
customfield.setHidden(true);
customfield.setRequired(false);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vishal
I still strongly recommend creating an extra field configuration and mapping the specific issue types to the field configuration to make them required so that you're not depending on the user's javascript to be enabled on the browser (as is necessary for Behaviors to work).
However, here's some information that may help you with Behaviours. Jira required fields do not interfere with Behaviours. If Jira says it's required, you can't make it optional with '.setRequired(false)'. You can however keep the field optional and map the Behaviour to the issue types where you do want the requirement and do 'setRequired(true)'.
On the other issue types, you'd map it to a script that says 'setHidden(true)'.
I'd use the initialiser scripts rather than a server side script as you only need it to run once and doesn't need continuous updated (unless you want to change the behaviour depending on the user input).
Hope this helps
Kind regards
Jorden
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Jorden Van Bogaert could you please check what's wrong with this ?
I am running it on all issue types of that project & expecting the desired output but its not working fully, it does make the field required on issue type "ABC XYZ" but not hiding them from remaining issue types, though they are not required.
I am running this in behaviour :
def custfield = getFieldById ("customfield_xxxxx")
custfield.setHidden(true);
String issueType = IssueContext.getIssueType()
if (issueType == "ABC XYZ" ) {
custfield .setHidden(false);
custfield .setRequired(true);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'll check now and let you know asap.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vishal
The following code works for me:
def custfield = getFieldById("customfield_11823")
custfield.setHidden(true);
String issueType = getIssueContext().getIssueType().getName()
if (issueType == "Task") {
custfield.setHidden(false);
custfield.setRequired(true);
}
Let me know if it works for you to.
Kind regards
Jorden
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Jorden Van Bogaert unfortunately, no, its not working fully as its unable to hide the custom field from other issue types, rest all is working as expected though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vishal
Did you put the code as an initialiser? For me it seems to work fine, but I've added it as an initialiser.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Jorden Van Bogaert I was adding fields & running the script for individual field earlier but even after running it as initialiser, it's not working for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mm, now I'm a bit clueless :/ it works fine here, so I'm not sure what may differ... What Jira & Scriptrunner version are you using?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Jorden Van Bogaert honestly, there is no reason for it to not to work but somehow its not :)
We are using scriptrunner v. 5.6.9.
Though for now I have come up with the workaround, a dumb one but it's the only way as intelligent ways are not working :P
I have created two behaviour one with all issue types ( except one which needs them ) where it's hiding the custom fields & second with the issue type where I want the fields to be required. Its working but I'll have to check why the simple code is not working.
Thanks for the help though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I solved this exact issue-
This should resolve the "requirement" type on other issue types. If the field you want to mark required is in more than one issue type but you only want it required for one issue type, I would suggest creating a duplicate custom field and assign it to the associated issue types and leave that one unmarked as required. Probably not best practice in reporting, etc. since the fields will be the same and unable to be differentiated but it will work.
Hope that helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vishal ,
You should set an exclusive field scheme for this special IssueType. Associating an issue type with a different field configuration.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ollie Guan thanks for the suggestion, I am actually looking for something where in all my Issue Types to use default screen scheme only ( I don't want to create separate for the said issue type ), I am trying to use behavior & is trying to make the fields visible & required for only one issue type.
Do you have any suggestion ? You may see my conversation with Jorden to know what exactly I am doing.
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.