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")
}
}
}
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?
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.