We have an issue where we need descriptions to be added to certain asks. Some of the engineers don't want to fill the data in and just type a space or a bunch of spaces in the required custom text field. How can I prevent this from being accepted?
I found this article: https://community.atlassian.com/t5/Jira-questions/Can-I-prevent-leading-and-trailing-whitespace-for-single-line/qaq-p/275894 which looks close to what I need, but I'm not sure how to write out the custom field name.
This article was also close https://community.atlassian.com/t5/Jira-questions/Validator-to-restrict-spaces-on-custom-field-text/qaq-p/865782, but if they actually type in a description, then that's not quite what I'm looking for either.
Any assistance with writing the groovy script (post function) that may be needed would be helpful.
I would put the check as a validation on the transition instead of a post function. Post functions will not prevent the user from just adding spaces to the description, if you do it as a validation the issue cannot move forward until the conditions are right.
But I would consider a different approach, because setting a validation only teaches the developers a different way of bypassing it. I would consider training them on how to write issues, and perhaps have a gate keeper (maybe their managers) that checks the issues to make sure the developers following the process. If the do not write a good description, push the issue back to them to correct it. A tool can do so much, but if a developer does not want to follow a process they will find a way around it.
A validator makes sense. I definitely agree with training. The field is already a required field. Assuming I needed to so a Simple Scripted Validator, what would that look like?
I was trying to see if something like
!cfValues["FIELD_NAME"]?.value.contains(" ")
would work, but I don't want to prevent any/all spaces from being entered. Rather, I want to make sure the first character is not a space.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Something like this should do it. This will remove any leading white spaces and compare it to the original description value.
String desc = issue.description
if (desc.trim() !== desc) {
// error
}
But it will not prevent anyone from enter a dot or any other character that is not a space.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for sending this. I've been trying it out and getting a huge compilation error. Trying to resolve that. Until then, I'll let you know how it goes.
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.