Conditionally show a fragment

Julia
Contributor
April 28, 2023

Using ScriptRunner Fragments

Hey Atlassian Community! I am trying to only display a fragment when certain conditions are met. 

What I need help finding is how to actually get the fragment to show when these conditions are met. Using the script console I can verify that the script is finding everything outlined here, but I can't find the syntax to say "ok now show the fragment". 

OR if there is another way to access the type of a child issue that is more straightforward than this please let me know.

Any ideas? 


Issues.search("issuekey in childIssuesOf('$issue.key')").each { child ->
def childKey = child.key

def childType = child.issueType

log.warn "$childKey, $childType"

if ( jiraHelper.project?.key == "PTDEMO" || jiraHelper.project?.key == "MSPG" && childType.name in "Project Resources" && issue.issueType.name == "Initiative" && issue.status.name !in ["Created","Roadmap Item Triage","Roadmap Backlog","Will Not Do","Ready for Design","Design","Ready for Delivery","Delivery","QA Validation","Pending Release","GA/Shipped","Bugtail"]){

//display the fragment...

}

}



1 answer

0 votes
Bellina Bui April 28, 2023

Try 

return true 

return false :) 

Julia
Contributor
April 28, 2023

I tried this and it isn't working. In the conditions section of fragments it says "Under what circumstances should this link be displayed. Must be either a plain script or an implementation of com.atlassian.plugin.web.Condition" 

Am I trying to do something that is just out of scope of fragment conditions? 



Issues
.search("issuekey in childIssuesOf('$issue.key')").each { child ->

def childKey = child.key

def childType = child.issueType

log.warn "$childKey, $childType"

if ( jiraHelper.project?.key == "PTDEMO" || jiraHelper.project?.key == "MSPG" && childType.name in "Project Resources" && issue.issueType.name == "Initiative" && issue.status.name !in ["Created","Roadmap Item Triage","Roadmap Backlog","Will Not Do","Ready for Design","Design","Ready for Delivery","Delivery","QA Validation","Pending Release","GA/Shipped","Bugtail"]){

return true

}

}

Suggest an answer

Log in or Sign up to answer