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,463,576
Community Members
 
Community Events
176
Community Groups

ScriptRunner listener not working within Portfolio

I have a new listener listed below that copies the fixed deadline date down the portfolio hierarchy, but the date isn't showing up as changes within Portfolio.  The correct date shows up on the linked lira issues and in the issue search but not within Portfolio. Any suggestions as to why this would happen and how to correct it would be so helpful.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.issue.search.SearchQuery
import com.atlassian.jira.issue.search.DocumentWithId
import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("com.acme.FixedDeadlineDate")
log.setLevel(Level.DEBUG)

Issue issue = event.issue

def key = issue.getKey()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def FDDfield = customFieldManager.getCustomFieldObjects(event.issue).find { it.name == "Fixed Deadline Date" }
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def parentLink = customFieldManager.getCustomFieldObjectsByName('Parent Link')[0]
def customFieldValue = issue.getCustomFieldValue(parentLink)
def parentKey = (String) customFieldValue
def parentIssue = issueManager.getIssueObject(parentKey)
def parentValue = issue.getCustomFieldValue(FDDfield)
log.debug("ParentLink Value = " + customFieldValue)

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchService = ComponentAccessor.getComponent(SearchService)
def jqlSearch = "issuetype in (Feature,'Forecasting Placeholder') and issuekey in childIssuesOf(" + key + ")"
def query = jqlQueryParser.parseQuery(jqlSearch)
def results = searchService.search(user,query, PagerFilter.getUnlimitedFilter())
results.getResults().each {documentIssue ->;

def childIssue = issueManager.getIssueObject(documentIssue.id)
def changeHolder = new DefaultIssueChangeHolder()
def childValue = childIssue.getCustomFieldValue(FDDfield)
def issueIndexManager = ComponentAccessor.getComponent(IssueIndexingService)
FDDfield.updateValue(null, documentIssue, new ModifiedValue(childValue, parentValue), changeHolder)

issueIndexManager.reIndex(documentIssue)
}

1 answer

We have determined this isn't related to scriptrunner after all. This is directly related to Portfolio for Jira. We tested out this field within another environment that doesn't have the script in place and found that the date is not matching what is on the Jira Issue. It is actual off my one day. 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events