Hello Community,
How can i do this one with script runner or any other way.
Scenario:
I have text custom field "project" and it has string limit of 16 characters or less(Done with script runner behaviors). When the user enter the input with any spaces eg: "project name" then its should throw an error for the space in the text field.
The final input should be only once character not two. eg : "projectname".
Hi @niranjan ,
You can use this snippet :
def textField = getFieldById("customfield_11000")
def textFieldValue = textField.getValue()
if (textFieldValue.contains(" ")){
textField.setError("this field can not contain spaces.")
}
else {
textField.clearError()
}
Antoine
Hi @Antoine Berry Thank you for the script. Should i use the behaviors to execute this script or any other option.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can save as is, the script since the getValue() method will return a string, you can use contains().
Yes behaviours is the right option, make sure you have updated the field id or use
getFieldById(getFieldChanged())
instead.
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just adding to this, I used the script below to see if Summary field has spaces. (Summary is not a custom field and answer above was not working for me). Returns true/false for Simple Scripted Validator. Note the exclamation point in front.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.IssueTypeManager
!issue.summary.contains(" ")
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.