Hi,
I'm trying to create a behaviour that checks the content of Description. If the field contains the string "We can't log you in right now" it should set an error but I can't get it working. Any idea how can i go about this?
Hi @Joel Batac
Could you provide some more information, i.e. when do you want this behaviour to trigger? Is it on the Create, Edit or some other screen?
I am looking forward to your clarification.
Thank you and Kind regards,
Ram
Hi, during creation in the Service desk form.
For your requirement, you must create a Server-Side Behaviour configuration for the Description field.
Below is a sample working Behaviour code:-
import com.onresolve.jira.groovy.user.FieldBehavioursimport groovy.transform.BaseScript@BaseScript FieldBehaviours behavioursdef description = getFieldById(fieldChanged)def descriptionValue = description.value.toString()description.clearError()def wordArray = ['We', "can't", 'log', 'you', 'in', 'right', 'now'] as String[]if (descriptionValue && containsWords(descriptionValue, wordArray)) { description.setError('Error')}static boolean containsWords(String input, String[] words) { def lastInput = input.split(' ').last() if (lastInput.startsWith('n') && lastInput.endsWith('w') && input.split(' ') == words ) { Arrays.stream(words).allMatch(input::contains) }}
Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below is a screenshot of the Server-Side Behaviour configuration.
Below are a couple of test screenshots for your reference:-
1. If the Description field contains all the text the error message is displayed as shown in the screenshot below:-
2. If the Description field doesn't contain all the text specified, the error message will not be displayed as shown in the screenshot below:-
I hope this helps to solve your question. :-)Thank you and Kind regards,Ram
Has your question been answered?
If yes, please accept the answer provided.
It looks like you're new here. Sign in or register to get started.