Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Post function script to update linked items Edited

I have written a scriptrunner post function that should update the status of a linked item when its run. Essentially, when our dev team reviews and accepts a client issue for development we want to clear the assignee (with conditions) and reviewed flags on the client issue. This script i have generates no sytax errors and runs without issue but doesnt seem to want to update the linked item: 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.link.IssueLink

def issueService = ComponentAccessor.getIssueService()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def v3Reporter = issue.getReporter()
def linkType = ["Inducted"]
def linkMgr = ComponentAccessor.getIssueLinkManager()
def desc = "start"

for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
if (linkType.contains(link.issueLinkType.name)) {
MutableIssue clientIssue = link.sourceObject as MutableIssue

def customFieldManager = ComponentAccessor.customFieldManager
def clientAssignee = clientIssue.getAssignee()
def review = customFieldManager.getCustomFieldObjectByName("Reviewed by Product Team")
def reviewValue = clientIssue.getCustomFieldValue(review)
if (v3Reporter == clientAssignee){
clientIssue.setAssignee(null)
clientIssue.setCustomFieldValue(review, "Yes")
} else {
clientIssue.setCustomFieldValue(review, "Yes")
}
}
}

1 answer

ok - so i now realize that i need to use the issue service to make the updates and have re-written to this but the update doesnt seem to be valid: 

import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.customfields.option.Options
import com.atlassian.jira.issue.link.IssueLink

IssueService issueService = ComponentAccessor.getComponent(IssueService);
def customFieldManager = ComponentAccessor.getComponent(CustomFieldManager);
def optionsManager = ComponentAccessor.getComponent(OptionsManager);
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def v3Reporter = issue.getReporter()
def linkType = ["Inducted"]
def linkMgr = ComponentAccessor.getIssueLinkManager()
def user = ComponentAccessor.getJiraAuthenticationContext().loggedInUser

for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {
if (linkType.contains(link.issueLinkType.name)) {
def clientIssue = link.sourceObject
def clientAssignee = clientIssue.getAssignee()
def review = customFieldManager.getCustomFieldObjectByName("Reviewed by Product Team")

if (v3Reporter == clientAssignee){
issueInputParameters.setAssigneeId(null)
issueInputParameters.addCustomFieldValue(review.id, "Yes")
} else {
issueInputParameters.addCustomFieldValue(review.id, "Yes")
}
def update = issueService.validateUpdate(user, clientIssue.id, issueInputParameters)
if (update.isValid()) {
issueService.update(user, update)

}
}

 

any thoughts on what i'm missing? 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New cloud apps roundup - June 2021

Since our last roundup in April, Atlassian's Marketplace Partners have added over 100 new cloud apps to the Atlassian Marketplace to help your teams work more efficiently. Let’s take a quick look a...

492 views 6 12
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