Challenge:
When a colleague enters a text in the comment, the script runner should use a behavior to check whether he has written the word <men>. If this is the case, the word <men> will be replaced by <men / women>.
Condition:
Under no circumstances should the wrong word be found in history. Therefore, the listener and post function are unfortunately not an option.
Currently:
I can do this for all possible fields without any problems, only the comments bitch.
Question:
Does anyone have any idea how I can use behavior to make sense of the comments? I haven't found anything going that way.
For your requirement, Behaviour may not be the correct approach.
The reason is that the Behaviour works only on specific screens, i.e. Create Issue, Update/Edit Issue, Assign Issue, and Workflow Transition screens.
For more information, please visit the Behaviour Limitation section in the ScriptRunner Documentation.
If you want the comment to be updated on the Workflow Transition screen, using the Behaviour, this is doable. For example:-
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def comment = getFieldById(fieldChanged)
def commentValue = comment.formValue.toString()
if (underlyingIssue != null) {
if (commentValue.contains("men")) {
def updatedValue = commentValue.replace("men", "men/women")
comment.setFormValue(updatedValue)
}
}
Please note, this sample code is not 100% exact to your environment. Hence, you will need to make the required modifications.
Below are a few test print screens:-
1) First, the sample issue is created as shown below:-
2) Next, the issue is transitioned to In Progress, and the transition screen appears as shown below:-
3) Next, I am going to enter the word men into the comment field as shown below:-
4) Finally, after entering the word men, once I click out of the comment field, as expected, the word updates to men/women as shown below:-
I hope this helps to answer your question. :)
Thank you and Kind Regards,
Ram
That looks good. I understand the limitation of the Behaviors. If I could manage to switch to the editing screen when clicking on a comment, would a behavior also take effect? Then it would be ensured that nothing is written to the history. Would it work?
Since our colleagues do not only enter comments in the context of a status change, I unfortunately cannot take the path. I would also have to make sure that the same behavior applies when changing the comments.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To answer your question, I have tested the example code I provided in my previous comment, and it works on the Edit screen as well and not only on the transition screens.
So, if the word man is added to the Edit screen's comment field, and you were to click out of the box, it will automatically change to man/woman.
I hope this helps to answer your question. :)
Thank you and Kind Regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_
Yes, I tested it too. And it works great in edit mode. But if a comment is edited or recorded on the IssueScreen via the comment button, then unfortunately not. Here I am currently researching how I can get this resolved.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kay Domschke : Dear Kay,
do you have a solution for your requirement?
We do have a very similar one...
Thanks for your reply,
Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, we use the gdpr plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Kay Domschke Thanks for your reply!
We are trying to manage it using script runner --> I will open a ticket in their system.
KR, Christian
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.