The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Dependent Counter Scripted Field not displayed as custom field in issue

sharma-shweta
September 23, 2013

I was tesing out some examples for Dependent Counter fields in JIRA from https://jamieechlin.atlassian.net/wiki/display/GRV/Scripted+Fields#ScriptedFields-QuickStartforExperimenting. I copy pasted some scripts into the scripted field column and saved it.

But the dependent counter custom field doesnt appear on my issue page.

Am I missing out on some step?

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
September 29, 2013

hello Shweta,

you are getting count as 1 because you are checking for number of link types with name Cloners in your jira. Probably it always return 1

As prasad suggested, you need to get links from the issue as

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.link.IssueLinkManager;
import com.atlassian.jira.issue.link.IssueLink;

IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager();

List<IssueLink> issueInwardLinksList = issueLinkManager.getInwardLinks(issue.getId());

int inCount=0;

for(IssueLink issueLink : issueInwardLinksList)
{	
	if(issueLink != null && issueLink.getIssueLinkType().getName().equals("Cloners"))
	{	
		++inCount;
	}	
}

List<IssueLink> issueOutwardLinksList = issueLinkManager.getOutwardLinks(issue.getId());

int outCount=0;

for(IssueLink issueLink : issueOutwardLinksList)
{	
	if(issueLink != null && issueLink.getIssueLinkType().getName().equals("Cloners"))
	{	
		++outCount;
	}	
}
int totalCount=inCount+outCount;
return totalCount;

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
September 24, 2013
0 votes
sharma-shweta
September 24, 2013

Hi Jamie,

Yea you are right, I hadnt linked it with the screen..

Thanks!

I was trying to get this script to run but its not displaying the right value. I want to display the number of cloned links in a issue. BUt when I run this script I always get 1.

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.link.IssueLinkType

import com.atlassian.jira.issue.link.IssueLinkTypeManager

ComponentAccessor componentAccessor= ComponentAccessor.newInstance()

Collection<IssueLinkType> issueLinkTypes=componentAccessor.getComponentOfType(IssueLinkTypeManager.class).getIssueLinkTypes();

count = 0;

for (IssueLinkType linktype : issueLinkTypes) {

    String name=linktype.getName();

    if(name.equals("Cloners")){

        count++;

    }

}

return count;

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
September 23, 2013

Have you associated it with the issue type? Is it on the view issue screen? Check with the "where's my field" thing.

Also check the logs to make sure it's not failing.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.