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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
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


#if ($value > 5)

<h2> id=value1> $value </h2>

#else if( $value < 5)

<h2 id=value2> $value </h2>



{ background-color: tomato;​color: white; }


{ background-color: green;​color: white; }


​I#if ($value > 5)

<h2> id=value1> $value </h2>

#else if( $value < 5)

<h2 id=value2> $value </h2>



{ background-color: tomato;​color: white; }


{ background-color: green;​color: white; }


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.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')"
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() }

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
import com.atlassian.greenhopper.manager.issuelink.EpicLinkManager
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?

.red-epic-count { background-color: tomato; color: white; }
.green-epic-count { background-color: green; color: white; }

#set( $Integer = 0 )
#set($epicCount = $Integer.valueOf($value))
#if($epicCount > 5)
<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

Atlassian Community Events