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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Advanced Roadmaps

3 short videos to help you get started with Advanced Roadmaps

Hi community, I’m Roi, a product manager working on Advanced Roadmaps for Jira. While Advanced Roadmaps is a powerful tool to plan and track work at scale, we know it can be challenging to get star...

6,584 views 25 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you