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

ScriptRunner listener not working within Portfolio

SMAtlassianMber October 15, 2019

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.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.index.IssueIndexingService
import org.apache.log4j.Logger
import org.apache.log4j.Level

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

Issue issue = event.issue

def key = issue.getKey()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def FDDfield = customFieldManager.getCustomFieldObjects(event.issue).find { == "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 =,query, PagerFilter.getUnlimitedFilter())
results.getResults().each {documentIssue ->;

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


1 answer

0 votes
SMAtlassianMber October 18, 2019

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
AUG Leaders

Atlassian Community Events