Hide Transition Button but not disable the Transition

Pawel Rozek July 7, 2017

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?

3 answers

1 accepted

5 votes
Answer accepted
adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2017

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 }

 

Jayaram R.D January 31, 2019

   I tried to use above codes   to hide transition from user. As in our team flow we have two issues Parent and child. Changing status in child issue type will initiate status change of parent issue type. But due to hiding transition in parent issue type, status not moving. 

3 votes
Joshua Yamdogo @ Adaptavist
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2017

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.

Pawel Rozek July 10, 2017

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

 

adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2017

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

Pawel Rozek July 11, 2017

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

adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2017

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

Pawel Rozek July 11, 2017

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

adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2017

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
}
Pawel Rozek July 11, 2017

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

Like Mahesh Kallepalli likes this
adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2017

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

Mahesh Kallepalli January 30, 2020

@adammarkham @Pawel Rozek 

 

I have copied the same code we are facing issue that transition is hiding and automatically parent issue status is also changing our attention is to hide transition's from parent and status will updating from sub-task automatically (i.e done).

2 votes
Aayush Mohanka December 23, 2020

I too have a similar question.
I have a transition hidden using condition but wanted to perform same using rest call.
how can I use rest call to perform that hidden transition?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events