How can I make a custom field required on a transition with ScriptRunner?
Let's say the field has the name "xx yyy".
Many thanks in advance.
The standard answer is "use a validator" - it should be as simple as saying "customfield 'xx yyy' is not empty", you might not even need a script for it.
You might also be able to do it with a Behaviour, which works on the UI side rather than on the back-end in the workflow with a validator, but that could be a bit more complex to implement and won't catch it if people are using the REST API.
1. Yeah, I just wanted to be clear there were other options
2. Yep, you mentioned Scriptrunner - Jira has a couple of very simple validators built in, but nothing of any serious usefulness. SR lets you create validators that can do almost everything
3. The pseudo code is really just "if custom field has value, return true". I don't usually do copy and paste, but in this case, it's easy enough that I can probably do it from memory
def customField = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
assert customField: "Could not find custom field with name $customFieldName"
if issue.getCustomFieldValue(customField) return true
The transition screen cannot be closed though all the fields are not empty.
Can you help please?
1. The code:
def customField = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).findByName("Wiedervorlage-Datum")
assert customField: "Could not find custom field with name Wiedervorlage-Datum"
if (issue.getCustomFieldValue(customField)) return true
2. The two red points on the console:
Hi, Jira users! Do you use Jira alongside Microsoft Teams? We want to hear how you’ve used the power of Jira Cloud and Microsoft Teams (via the Jira Cloud for Microsoft Teams app) to achieve a team...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events