Making a field non-mandatory using ScriptRunner scripts

Hi,

I have a field mandatory in couple of projects sharing a single workflow. 
I am making this field mandatory using workflow validators on create issue screen for all these projects.

Now there is a project (ABC), and I don't want the field to be mandatory in it. 
Could someone tell me how to do that? 
How can I make an exception for that project without disturbing all the other projects?

P.S. Creating a new field configuration is not ideal for me. And would be the last approach.

Many thanks,
Tayyab 

3 answers

1 accepted

Accepted Answer
1 vote

Field configurations make  field mandatory from creation time, so I assume you're using validators because you need them optional for part of the lifecycle.  (If you need them mandatory throughout, then you absolutely should be using field configurations)

So, the simple approach - copy the workflow in use, put it in a new workflow scheme for the new project, and strip the validators out of it.

I would need to create both a new workflow and a new workflow scheme for it?

Yes, that's one of the things workflow schemes are for - to allow issues to follow different processes.

1 vote
Vasiliy Zverev Community Champion Mar 09, 2017

I would reccomend to use field configuration scheme beacause it garantee that after creation value for these fields will not be set to null. And these make it simpler to use the same workflow into different projects.

I created a new field configuration, but since the fields are being made mandatory using a workflow validator, I can't make them optional with the new field config, right? 

Vasiliy Zverev Community Champion Mar 09, 2017

You are rigth. That is field configuration for. You have the same workflow, but different mandatory fields into different projects. 

In your case I would reccomend you to define where to reasilse logic for mandatory fields: into field config or into workflow validator.

Benefits for field config:

  • mandatory fields will not be made empty 
  • will be marked with red star on create screen
  • more flexible to use into different projects

 

Plus, with field configs, you can carry on using the same workflows.

 

If you want to use script runner plugin then You can use a behaviour section to make a field mandatory for a specific project and issue type

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 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...

26,302 views 2 7
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