Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Validator

Aswathi D
Contributor
March 20, 2023

Hi 

I need to add a validator to story workflow as below
Transition is from in progress to in analysis
Validator is ...the sub tasks with request type field which contains values A ,B should be closed
How can I add this ?

1 answer

1 accepted

2 votes
Answer accepted
Tuncay Senturk _Snapbytes_
Community Champion
May 10, 2018

Hello,

Below code might help. Bear in mind that I did not test it

WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
JiraWorkflow workflow = workflowManager.getWorkflow(issue);
workflow.getLinkedStep(status).getActions();
Dalectric
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 Champions.
May 11, 2018

Nice one, that worked a treat.

For the current status I've used it as follows

workflow.getLinkedStep(issue.getStatus()).getActions();
Like Ahmadi Islem likes this
Tuncay Senturk _Snapbytes_
Community Champion
May 11, 2018

I'm glad to hear that it works ;)

Kleber Fonseca
Contributor
July 30, 2018

Hi @Tuncay Senturk _Snapbytes_

 

Please

 

I'm trying too work with a code like this but...

how can i get the results ??

I've read Atlassatian OnLine Documentation and I saw that "getLinkedSetp" method returns 

com.opensymphony.workflow.loader.StepDescriptor

I would like to get the possible transitions (actions) basead on a issue state, just like the code above.

But, I have to fire a transition if I found a particular action. 

So, I must handle the Action Name (to search) and the Action ID (to fire) of the actions returned by "workflow.getLinkedStep( issue.getStatus()).getActions()

Is it possible?

Thanks in Advance

Kleber Fonseca
Contributor
July 30, 2018

@Tuncay Senturk _Snapbytes_

 

Forget it

I get it

import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.workflow.JiraWorkflow
import com.opensymphony.workflow.loader.ActionDescriptor

JiraWorkflow workflow = ComponentAccessor.getWorkflowManager().getWorkflow(  _issue_  )

 

ActionDescriptor action

int actionID = 0
def actions = workflow.getLinkedStep( issuePai[0].getStatus() ).getActions().iterator()
while ( actions .hasNext() )
{
action= (ActionDescriptor)actions .next()

if( action.getName() == "my condition")
actionID= action.getId()
}

Like Ahmadi Islem likes this

Suggest an answer

Log in or Sign up to answer