Hide Transition Button but not disable the Transition

Is it possible to Hide Transition Button but not actually disable the transition in a specific Status?

Here is a use case:

I have a ScriptRunner Post Function that once user Reopens a ticket (Move from DONE to REOPEN) it finds all issues that have dependencies (custom field called "Segment") and also reopens them. 

My Re-Open workflow step pops up a screen to let user input reasons why they reopening the issue, but the dependencies issues are reopened using a different workflow transition using a ScriptRunner script and workflowTransitionUtil with workflow step called "DO NOT USE" for now

I would like to hide "DO NOT USE" button from the user but not disable the ability for the scriptRunner script to use this transition step as that user.

Is this even possible?

2 answers

1 accepted

1 vote

It may be easier to use IssueService to handle the transiton that way you can see in the logs if there are any errors. Please try transitioning the issues like below:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.TransitionOptions

// replace with your issue here
def issue = issue

def issueService = ComponentAccessor.getIssueService()

def currentUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()

def parameters = issueService.newIssueInputParameters()

// replace with id of the transition def actionId = 111 def transitionOptions = new TransitionOptions.Builder() .skipConditions() .skipPermissions() .skipValidators() .build() def result = issueService.validateTransition(currentUser, issue.id, actionId, parameters, transitionOptions) if (result.isValid()) { issueService.transition(currentUser, result) } else { log.warn result.errorCollection.errors }

 

Hi Pawel,

From what you've described, this definitely seems like something that is already built-in to ScriptRunner. If you go to the workflow step that you want to edit and click "Add Condition", you should see one called "Hide transition from user": Screen Shot 2017-07-10 at 8.56.04 AM.pngThis will make it so that the user won't be able to click the transition button, but you can still transition through the workflow using other means.

Thanks Joshua,

I have tried this method, however when I reopen my issue using my reopen workflow, I get an error:

org.ofbiz.core.entity.GenericTransactionException: Commit failed, rollback previously requested by nested transaction.

The error pops up on top of my reopen window as follows:image.png

 

Hi Pawel,

Do you get this error message without the condition in place? Can you try removing what Joshua suggested and see if you still get the same error?

Thanks,
Adam

Hi Adam,

I do not get this error message without the condition in place.

With the condition, it produces stack trace, but it is too big to add to this message, not sure how to add it to help

Hi Pawel,

Can you provide more details about the post-function you are using to reopen the ticket? The script or screenshot would be useful.

Am I right in thinking this is the only customisations you have on this flow?

Thanks,
Adam

Hi Adam,

High level, in a Post function of my Reopen script, I check against custom field called "Segment" a value, then based on that value, I check a bunch of if statements  and generate and use the JQL to find "issues". "issues" is an array of keys to the project that are in a closed state but have the dependency. This is the part that does the reopening of the issues from the array of issues:

if (issues) {
 log.debug("The segment is: "+issues)
    issues.each {
        arrayIssue = ComponentAccessor.getIssueManager().getIssueObject(it.toString())
        MutableIssue issueFromKey = issueManager.getIssueObject( "$arrayIssue" ) as MutableIssue
        log.debug("The issue: "+arrayIssue+" was auto-reopened by a post-function due to dependencies")
        workflowTransitionUtil.setIssue(issueFromKey as MutableIssue)
        workflowTransitionUtil.setUsername(currentUser)
        // 111 == AUTO-REOPEN ISSUE (DO NOT USE BUTTON)
        int workflowStep = 111
        workflowTransitionUtil.setAction(workflowStep)
        // validate and transition issue
        if (workflowTransitionUtil.validate()){
            workflowTransitionUtil.progress()
        }
    }
}

My "Reopen" Transition ID = 71 and the "DO NOT USE" Transition ID = 111. Note that Transition ID 71 has a screen, hence I have to separate them as I haven't figured out a way to use automation to reopen ignoring the screen.

Let me know if this helps

It may be easier to use IssueService to handle the transiton that way you can see in the logs if there are any errors. Please try transitioning the issues like below:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.TransitionOptions

// replace with your issue here
def issue = issue

def issueService = ComponentAccessor.getIssueService()

def currentUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()

def parameters = issueService.newIssueInputParameters()

def actionId = 111

def transitionOptions = new TransitionOptions.Builder()
    .skipConditions()
    .skipPermissions()
    .skipValidators()
    .build()

def result = issueService.validateTransition(currentUser, issue.id, actionId, parameters, transitionOptions)

if (result.isValid()) {
    issueService.transition(currentUser, result)
} else {
    log.warn result.errorCollection.errors
}

Hi Adam, 

This actually works great, it allows me to hide the workflow button, and it transitions the issue(s) correctly. Thank you for your help.

Pawel

Hi Pawel,

That's good to hear.

I've made my response an answer so you can accept it. That way other people can easily see the solution.

Thanks,
Adam

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

125 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you