Hi
We use Smart Checklist app also JMWE. In a workflow condition I wish to check if all items of the checklist are closed or the checklist is empty. In a jql this looks like:
("Smart Checklist" = allItemsClosed() OR Checklists is EMPTY)
How can I do this condition in groovy, i.e. with JMWE Scripted (Groovy) Validator?
Thanks!
Martin
you might want to raise a support ticket with the maker of Smart Checklists for that.
But there is an alternate solution : use jqlSearch in a Scripted condition. Something like:
!!jqlSearch("key=${issue.key} AND ("Smart Checklist" = allItemsClosed() OR "Smart Checklist" is EMPTY)
Hi David
Thanks for the tip. I've tried with Scripted Validator and global function "issues = jqlSearch", but parsing the jql string throws error 'The operator 'is' is not supported by the 'Smart Checklist' field.'
So I've found an alternate solution with Simple scripted validator (ScriptRunner) - this simply requires more lines of codes than a groovy script in JMWE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it works in ScriptRunner, it should work in JMWE. Can you share your script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David
sorry, I'm just back. ok, yes, I'm will be glad if this works also in JMWE. Here my script:
// prüft, ob in diesem Issue keine Checkliste vorhanden ist oder ob alle Checklist-Items erledigt sind
// Verwendung in SEB, Team 'Web', Transition 'In Test'
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.jql.parser.JqlQueryParser;
import com.atlassian.jira.web.bean.PagerFilter;
import org.apache.log4j.Logger
def logger = Logger.getLogger("com.css.scriptedfield")
log.setLevel(org.apache.log4j.Level.INFO)
// ---------------------------------------------------------------------------------------------
// dies hier ist nur eine Fix-Position für die Script-Console und ist im gespeicherten File zu deaktivieren:
//def issue = ComponentAccessor.issueManager.getIssueByCurrentKey("SEB-26846")
// ---------------------------------------------------------------------------------------------
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def IssueKey = issue.getKey()
log.debug("-----validieren für Team (Web), ob keine oder eine erledigte Checkliste vorhanden ist ")
log.debug("-----IssueKey: " + IssueKey)
log.debug("-----user: " + user)
def jqlSearch = "key=" + IssueKey + " AND (Team=Web AND ('Smart Checklist' = allItemsClosed() OR 'Smart Checklist' is EMPTY) OR (Team!=Web))"
def query = jqlQueryParser.parseQuery(jqlSearch)
log.debug("---------jqlSearch: " + jqlSearch)
log.debug("---------query: " + query)
def results = searchService .search(user,query, PagerFilter.getUnlimitedFilter())
if (results.total > 0) {
log.debug("-----Resultat: "+results.total+" Validator => true - Transition kann ausgefuehrt werden")
return true
}
else {
log.debug("-----Resultat: "+results.total+" Validator => false - Transition nicht ausfuehren")
return false
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this code should work as-is in a Scripted (Groovy) Validator. However, it could also be greatly simplified:
!!jqlSearch("key=${issue.key} AND (Team=Web AND ('Smart Checklist' = allItemsClosed() OR 'Smart Checklist' is EMPTY) OR (Team!=Web))",1)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David
really great! Thank you very much - and now: Merry Christmas!
Martin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are glad you're using Smart Checklist.
We can say that the solution recommended above is accurate. If you have any additional questions in regards to the usage of the Smart Checklist, feel free to reach out to us at smartchecklist@railsware.com.
Best regards,
Olena
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.