Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,136
Community Members
 
Community Events
176
Community Groups

"Script to trigger REST API call " code in adaptivist library is throwing 404 error

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 .

2 answers

1 accepted

0 votes
Answer accepted

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.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events