During a transition I am editing the comments field and I am trying to leverage a behavior to check to make sure the comment is formatted correctly. I am able to apply the transition and there is no error. When I open the next transition that contains a comment field, it shows an error, but I am unable to edit the comment that has the error. I am thinking that the behaviors only get evaluated when the dialog is initialized as opposed to when the user applies the transition.
def commentField = getFieldById(getFieldChanged())
def validString = true
CommentManager commentMgr = ComponentAccessor.getCommentManager()
// I believe the next step will return the comment I just added during the transition
def comment = commentMgr.getLastComment(underlyingIssue)
if ( comment ) {
String commentText = comment.getBody()
// Do some string evaluations....
}
if (commentField) {
if(validString) {
commentField.clearError()
commentField.setValid(true)
} else {
commentField.setError("ERROR in comment")
commentField.setVald(false)
}
}
Hi @Kyle Rotte
If you applied the behaviour on the field with a server side script, the behaviour is executed when that field value changes.
If you had applied the behaviour to the initialiser, then it gets executed when the form is loaded for the first time.
And for your requirement, do you want to tie the behaviour to a specific transition only? If yes, you could use something like
if (getActionName() == "transition name") {
//
}
Thank you for the response. I have the behaviour tied to a field (and not an initializer). I do not need to tie it to a specific action because I want it to apply to any action that has a screen with a field on it.
The behavior does not appear to be getting called every time the value is changed because I am able to submit a comment that does not meet the validation criteria. Is the following code the best way to get a comment that was being edited?
def comment = commentMgr.getLastComment(underlyingIssue)
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.