Error(s) occurred.
An error occurred while trying to delete event 20171010T225744Z--76744798@confluence.abc-dev.net.au.
Every time I try to delete future instances of two reoccurring events, I am getting the above error.
I am able to delete each individual instance of the event, however this will take me forever to do as I originally set up the event as reoccurring with no end dates.
Anyone have any clues?
Hi @Diana Gorv
I don't know if you've pasted the code exactly as you have written it on the workflow PF, but you have three typos:
import com.atlassian.jira.event.type.EventDisptachOption
import com.atlassian.jira.bc.user.sedarch.UserSearchService
ComponentAccessor.getIsuseManager().updateIssue(loggedInUser,issue,EventDispatchOption.Issue_UPDATED, false)
When I corrected these error your PF (I ran it on the console, so I made a few changes) worked, BUT it needed some changes. As I said, running the code on the console like the following worked fine. However, if you want to test it on your instance, change the "SP-1" with an issue of your instance. This was just for test
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.user.search.UserSearchParams
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.application.ApplicationAuthorizationService
import com.atlassian.jira.issue.MutableIssue
def versionManager = ComponentAccessor.getVersionManager()
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("SP-1") as MutableIssue
def project = issue.getProjectObject().getId()
def version = versionManager.getVersionsUnreleased(project, false)
def resolution = issue.getResolution()
//def earliestUnreleasedVersion = versionManager.updateIssueFixVersions(issue,version) THIS LINE WILL ADD ALL VERSIONS TO YOUR ISSUE
//bypass user permissions so fix version can be set
UserSearchParams.Builder paramBuilder = UserSearchParams.builder()
.ignorePermissionCheck(true)
def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def jiraServiceContext = new JiraServiceContextImpl(loggedInUser)
def applicationAuthorizationService = ComponentAccessor.getComponent(ApplicationAuthorizationService)
def users = ComponentAccessor.getComponent(UserSearchService).findUsers(jiraServiceContext, "",paramBuilder.build())
try {
if (loggedInUser == users && resolution != 'Unresolved'){
issue.setFixVersions([version.first()])
ComponentAccessor.issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.ISSUE_UPDATED, false)
log.warn([version.first()])
}
} catch (Exception e) {}
Now, the following line you have, and I commented out, was adding all versions to the issue:
def earliestUnreleasedVersion = versionManager.updateIssueFixVersions(issue,version)
I would place your script on a workflow PF and not on a listener, and most likely your code (without testing it on a workflow) should look like this:
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.user.search.UserSearchParams
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.application.ApplicationAuthorizationService
def versionManager = ComponentAccessor.getVersionManager()
def issueManager = ComponentAccessor.getIssueManager()
def project = issue.getProjectObject().getId()
def version = versionManager.getVersionsUnreleased(project, false)
def resolution = issue.getResolution()
//bypass user permissions so fix version can be set
UserSearchParams.Builder paramBuilder = UserSearchParams.builder()
.ignorePermissionCheck(true)
def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def jiraServiceContext = new JiraServiceContextImpl(loggedInUser)
def applicationAuthorizationService = ComponentAccessor.getComponent(ApplicationAuthorizationService)
def users = ComponentAccessor.getComponent(UserSearchService).findUsers(jiraServiceContext, "",paramBuilder.build())
try {
if (loggedInUser == users && resolution != 'Unresolved'){
issue.setFixVersions([version.first()])
ComponentAccessor.issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.ISSUE_UPDATED, false)
log.warn([version.first()])
}
} catch (Exception e) {}
Try it and let me know if that works!
Hi @Alex Koxaras -Relational- thank you for catching my typos, I had to manually type it in since the script is on an air-gapped environment that I can't copy and paste :)
This script works! Thank you so much!!
A couple of notes for future viewers in case they still have trouble.
One last question, if a user had placed 2 Fix Versions, can they both be cleared and then set Fix Version? When I tested by editing an issue to be 23.Q3 and 23.Q4, pushed issue to done, the 2 Fix Version stayed.
I tried adding:
issue.setFixVersions(null)
But it didn't work. If not, I can still accept this an an answer.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you want something to clear the version you mean?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes! I had to include an || for my If statement to capture if a user had placed more than 1 fix version by mistake
if ((issue.fixVersions.size()>1) || (loggedInUser == users && resolution != 'Unresolved')){
issue.setFixVersions([]);
issue.setFixVersions([version.first()]);
ComponentAccessor.issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.ISSUE_UPDATED, false);
log.warn([version.first()])
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.