Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to validate custom multi-select field in regular editing/saving (without a workflow transition)

Alexander Jancauskas March 5, 2019 edited

Hi there,

I want to validate a custom field right in the moment when the user clicks the "Save" button. There is no workflow transition involved, just a regular edit.

I tried to solve this with Scriptrunner's "Behaviours" functionality (which is awesome btw!), but here's the problem: I have a multi-select field where I have to validate that each value of this field is chosen only once over the whole project. Now this works fine right in the moment when the user chooses a value - I can catch that via the Behaviour and check, if that exact value is chosen anywhere else, and thus prevent saving by throwing an error. But think about this case: The user might have opened the Edit screen and have chosen a value like "Value 1". At this time "Value 1" was not chosen in any other issue. Now before he is clicking the Save-button (maybe she/he is away for a few minutes), somebody else does exactly the same thing with a different issue, but is saving right away. And when our user comes back and saves the issue finally, there is no error and we end up with two issues where "Value 1" is chosen, which we don't want in any case.

So can I validate sth. like a custom field right at the "Saving-Event"?

Thank you for any hints,

Alex

1 answer

1 accepted

0 votes
Answer accepted
Max Foerster - K15t
Community Champion
March 5, 2019

Hi @Alexander Jancauskas

is there no way to instead implement this using a transition screen, a validator and not making this field available on the screen associated with the edit operation? Because so (and through the re-indexing post function) you should not run into such problems and could at the same time provide a detailed error message to the user, e.g. issue xyz has the selected option assigned already etc. But in general, this seems like a nasty corner case after all. :/

Best, Max

Alexander Jancauskas March 5, 2019

Hi Max,

I'll probably have to do it this way, yes - I was just wondering if there was any solution to this that I just don't know ;) And I didn't want to "rob" the user of the possibility to change the selected value once the transition is done. But I guess that's a tradeoff that I have to make!

To me it seemed like a pretty obvious use case, but yes - I see that this is only a problem, if you want to validate against values outside of the current issue context, and so it is probably more or less a corner case.

Max Foerster - K15t
Community Champion
March 5, 2019

Do you have additional validations on fields for this issue? So an additional transition/screen would be less inconvenient when offered to users? Have done this before but additionally restricted this "Details" transition to specific roles. 

Alexander Jancauskas March 6, 2019 edited

Yes, there are some additional validations, and there is even a transition screen. I was just wondering if there was a possibility to have sth. like a workflow validator jumping in every time a user is regularily editing and saving an issue via the Edit screen, without having to rely on a transition.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events