Forums

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

Sriptrunner validator on transition: to check commet is not empty.

Kate April 3, 2023

Dear All, 

I need to add Scriptrunner validator to check comment for specific project. By now I got:

 

import com.atlassian.jira.component.ComponentAccessor

def project = issue.getProjectId()
if(project == {{id}}){
    {{*need to add comment validation here}}
    if(comment){
        return true
    }
}
else{
    return true
}

2 answers

2 accepted

1 vote
Answer accepted
Florian Bonniec
Community Champion
April 3, 2023

Hi @Kate 

 

You can try something like that

import com.atlassian.jira.component.ComponentAccessor

def value = true

def project = issue.getProjectId()
if(project == {{id}}){
value = false
if (transientVars.get("comment")) { value =  true }
}
return value
regards
Kate April 3, 2023

Thank you! Now I got error message 

" XINFO: javax.script.ScriptException: ReferenceError: "comment" is not defined in <eval>"

for projects that don't meet conditions.

Kate April 3, 2023

Is there a method to define comment in validator?

Florian Bonniec
Community Champion
April 3, 2023

Do you have a screen on the transition ?

Kate April 3, 2023

yes

0 votes
Answer accepted
Vikrant Yadav
Community Champion
April 3, 2023

Hi @Kate , If you have Transition screen Then simply add Script Runner field required validator. 

No need to create custom validator. 

Comment Field.png

Suggest an answer

Log in or Sign up to answer