Hi Team ,
This is the below scenario when i want to configure Scripted field .
Field Name -: Color Epic Field
Template -: Custom Template
Template-:
#if ($value > 5)
<h2> id=value1> $value </h2>
#else if( $value < 5)
<h2 id=value2> $value </h2>
#end
<style>
#value1
{ background-color: tomato;color: white; }
#value2
{ background-color: green;color: white; }
</style>
I#if ($value > 5)
<h2> id=value1> $value </h2>
#else if( $value < 5)
<h2 id=value2> $value </h2>
#end
<style>
#value1
{ background-color: tomato;color: white; }
#value2
{ background-color: green;color: white; }
</style>
Script to find no of epic in issues
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.bc.issue.search.SearchService.ParseResult;
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.issue.search.SearchResults;
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.user.*
String key = issue.getKey()
final String jqlquery = "issueFunction in issuesInEpics('issuekey= $key')"
log.warn(jqlquery)
def Searchmanager = ComponentAccessor.getComponentOfType(SearchService) //call searchservice component
def CurrentUser = (ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()) as ApplicationUser
def parsequery = Searchmanager.parseQuery(CurrentUser, jqlquery) // method which returns of type Searchservice.parseresult
int count;
if(parsequery.isValid()) // use method isvalid to check the query validation
{ count = (Searchmanager.searchCount(CurrentUser,parsequery.getQuery())).toInteger() }
log.warn("${count.getClass()}")
return count
above code is correct , I believe custom template code is also correct but not giving expected results
But returning output1 (please check attachment) instead it should return output2(please check attachment )
here unnecessarily if statement is added , please resolve this issue .
When I tried your script, I found that you were missing an import for the SearchService... but also, I think this can be simplified with the @JiraAgileBean notation
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.pyxis.greenhopper.jira")
import com.atlassian.greenhopper.manager.issuelink.EpicLinkManager
@JiraAgileBean
EpicLinkManager epicLinkManager
def issuesInEpic = epicLinkManager.getIssuesInEpic(issue)
return issuesInEpic.size()
Also, in my environment, this ran in about 10ms compared to 25-30ms for your code (using the same epic with 6 issues)
And finally, your velocity template seems overly complicated, isn't the following what you are trying to achieve?
<style>
.red-epic-count { background-color: tomato; color: white; }
.green-epic-count { background-color: green; color: white; }
</style>
#set( $Integer = 0 )
#set($epicCount = $Integer.valueOf($value))
#if($epicCount > 5)
#set($class="red-epic-count")
#else
#set($class="green-epic-count")
#end
<h2 class="$class"> $value </h2>
Yes same thing , Thank you very much
Your help is much appreciated.
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.