Writing a behaviour for employee id function
Employee id starts with c,d,i +numerical number 5 digit
def activity = getFieldById("customfield_12945")
def activity_value = getFieldById("customfield_12945").getvalue().toString()
def regexStr = (?=^.{1,10}$)^([c,d,i]\\s*[0-9]{1,6})$
If (activity_value.matches(regexStr))
{
activity.setRequired(true)
activity.clearError()
}
else
{
activity.setRequired(true)
activity.setHelpText("")
activity.setError("Please enter employee id")
}
geting error in my regix function
Code will look like this,
def regexStr = ~/^(c|d|i)\d{5}$/
or
def regexStr = Pattern.compile(/^(c|d|i)\d{5}$/)
So whole code will look like this,
def activity = getFieldById("customfield_12945")
def activity_value = getFieldById("customfield_12945").getvalue().toString()
def regexStr = ~/^(c|d|i)\d{5}$/
if (activity_value.matches(regexStr)) {
activity.setRequired(true)
activity.clearError()
} else {
activity.setRequired(true)
activity.setHelpText("")
activity.setError("Please enter employee id")
}
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.