Forums

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

scriptrunner validator issue

Alexander Verzakov
Contributor
June 11, 2019

Hi.

I add simple validator, that need to check amount of attachments.

import com.atlassian.jira.component.ComponentAccessor
def cfm = ComponentAccessor.getCustomFieldManager()
try
{
def result = issue.getCustomFieldValue(cfm.getCustomFieldObject('customfield_10200')).value;
if(result.equals('Аварийная'))
{
log.error("заявка аварийная");
return true
}
else
{
if(issue.getAttachments().size()>=1)
{
log.error("заявка не аварийная, есть вложение. Заявка: " + issue.getKey());
return true
}
else
{
log.error("заявка не аварийная, нет вложений. Заявка: " + issue.getKey());
return false
}
}
}
catch(Exception e)
{
log.error("не получено значение поля Тип заявки");
return false
}

It is correctly defines the situation but successfully execute transition even validator need to return false.
What i am doing wrong?

 

 

1 answer

0 votes
Alexander Verzakov
Contributor
June 11, 2019

I think that this is a workaround?
https://jamieechlin.atlassian.net/wiki/spaces/GRV/pages/1212434/Validators

To disallow the transition you set invalidInputException to an instance of a new InvalidInputException.
Yep it's work's, but i not sure that "Workflow error" is proper solution.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events