Hi,
got an user picker field. When the issue is editing I want to check that the user in a certain user picker field is not the same as the logged in user (the person who is currently editing the issue).
Thought this would be easy with ScriptRunner Behaviours but somehow its not working.
It doesn't recognize the condition when editing from a valid user to my user.
Thanks in advance.
Hi @Andreas Lorz ,
It seems indeed to trigger only when you save the field value, so it will not dynamically display the error. Instead you could just use a script without condition on this field :
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def responsibleForReal = getFieldById(getFieldChanged())
def responsibleForRealValue = responsibleForReal.getValue()
def currUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
String currUserKey = currUser.getKey()
if (currUserKey == responsibleForRealValue){
responsibleForReal.setError("Please select someone else as the responsible for realization")
}
else {
responsibleForReal.clearError()
}
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're welcome ! Please consider accepting the answer if you are satisfied with it so other users can benefit from it as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The "condition" is used to define where one of the three attributes above (Optional, Writable, Shown).
While the server-side script is where you would put more complex conditions and actions such as what was suggested by Antoine.
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.