We are using workflow in combination with Scriptrunner to set a validator.The validator we are using is "Require comment on transition" We want this validator to be used for anyone except one user.
The reason for the above is that we are using a plugin to bi-sync two instances of Jira by field, workflow and thus validator. The plugin seems to work but fails at the moment we activate a workflow where the validator is active.
If we can add a condition on the script Require comment on transition(wich is possible on Simple scripted validator but not on comment on transition) like if the user is not x than the validator is enforced we would would be gratefull
If there is a other way, we would also be gratefull
Hi Ardjan!
If you use a Custom Scripted Field, you can use this script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.WorkflowActionsBean
import com.opensymphony.workflow.InvalidInputException
import com.opensymphony.workflow.loader.WorkflowDescriptor
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser.name
if (currentUser != "admin") {
def comment = transientVars.get("comment")
if (!comment) {
def workflowActionsBean = new WorkflowActionsBean()
def workflowDescriptor = transientVars.get("descriptor") as WorkflowDescriptor
def actionDescriptor = workflowDescriptor.getAction(transientVars.get("actionId") as Integer)
if (!workflowActionsBean.getFieldScreenForView(actionDescriptor)) {
throw new InvalidInputException("You need to provide a comment for this transition but no screen is in use." +
" Contact your administrator.")
} else {
throw new InvalidInputException("comment", "Please provide a comment for this transition")
}
}
}
You'll just have to change the "admin" to the user you want to exclude from being required to make comments.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much, i can confirm this solution works!
Your excellent premium response is higly appreciated!
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! Feel free to mark this answer as accepted if it solved your problem!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Do you have AMUTILS (free addon)?
Has the below option which I think would work for you.
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.