I'm attempting to set the Fix Version to the earliestUnreleasedVersion when an issue is resolved.
Our fix version list is by quarter:
23.Q1 << this being the earliestUnreleasedVersion
23.Q2
23.Q3
23.Q4
etc
When an issue is resolved, the Resolution field can be either "Done", "OBE", or "Won't Do".
I'm trying to use a post-function script to check when Resolution is not "Unresolved" (i.e. any of the resolved status above), then the Fix Version will automatically set to the earliestUnreleaseVersion (i.e. 23.Q1). In addition, if the issue was reopen, Resolution is cleared (that is another script already working), and once the issue is closed again, it should either keep the same earliestUnreleasedVersion, or clear any version is had and replaced with the next earliestUnreleasedVersion. (for example: an issue used to 23.Q1, but was finally closed until 23.Q2. Fix version needs to be only one, which is 23.Q2).
But my current script keeps prompting me to select my fix version, when I want it to automatically set the fix version.
import com.atlassian.jira.event.type.EventDisptachOption
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.sedarch.UserSearchService
import com.atlassian.jira.application.ApplicationAuthorizationService
def versionManager = ComponentAccesor.getVersionManager()
def project = issue.getProjectObject().getId()
def version = versionManager.getVersionsUnreleased(project, false)
def resolution = issue.getResolution()
def earliestUnreleasedVersion = versionManager.updateIssueFixVersions(issue,version)
//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())
if (loggedInUser == users && resolution != 'Unresolved'){
issue.setFixVersions([version.first()])
}
ComponentAccessor.getIsuseManager().updateIssue(loggedInUser,issue,EventDispatchOption.Issue_UPDATED, false)
Also, for attempt this, am I placing it in the right location? Instead of workflow's post function, should it be in listeners? Or Behaviors? How would the script would be for that since I believe calling methods would be different.
I had also review other questions similar, but none achieved my goals
Hi Brian,
I tested on my Cloud instance and ran into the same issue with inserting the Highlight macro in the middle of a sentence.
Highlight is one of the Adaptavist Content Formatting macros bundled with Confluence Cloud - it is not included in the server version, and not developed by Atlassian. I am going to move your question to the Adaptavist area of the forum to get the attention it needs from the vendor.
Thanks,
Ann
Oh! Thank you so much, @AnnWorley. I didn't realize it wasn't part of the default Confluence offering. I'm pretty new to Confluence and have sort of stumbled into being an admin by virtue of having past experience with similar systems. Thank you for moving it to the correct place!
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.