Hello everyone. I have following case : I want to block Resolving issues when they have some status (eg. New) from some user. If I type for example issue.setResolutionObject(null) , we will get status Resolved , but with Resolution Unresolved. How to correctly create this postfunction
I am not sure what the requirement is here, I am confused.
You appear to be trying to restrict the resolution to certain entries depending on status, but then using a post-function to set it to something. Those two things don't really mix, they're different parts of the process.
I can't see if you mean you want to stop people selecting the "wrong" resolution, or set a resolution for them when they use a transition.
So.
If you want to stop the user choosing the wrong resolution on transition, use workflow properties to limit the list to valid ones.
If you want to set the resolution for them, use a post-function. Your code for that appears to be doing something that's probably wrong in terms of process, but it should work. What I don't understand there is "I want to not change the status of issue after validation. If this issue New , this issue must be still New" - if you don't want to change the status, why are you running a transition to another status?
One last thing, @VasiliyZ asks "Does it means that resolution is set via issue edit?" and you replied "Yes". If this is true, it is wrong. You should never edit a resolution, it should only be set or cleared on transitions. If you are doing it, you have bad data and a broken process
Better create a validator. If resolution is entered then throw a error. I think it is a better solution.
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.
Okay , I will try to answer in more details . I have a postfunction:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.ResolutionManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.config.ConstantsManager
def resolutionManager = ComponentAccessor.getComponent(ResolutionManager)
def issueStatus = issue.getStatusObject().getName()
JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
User loggedUser = jiraAuthenticationContext.getLoggedInUser()
if(loggedUser.toString().split(":")[0] == "Bill") {
if (issue.assignee == null && issueStatus == "OPS Investigating")
{
issue.setResolutionObject(resolutionManager.getResolutionByName("Self Corrected"));
}
else
{
issue.setResolutionObject(null)
}
}
We can see field
issue.setResolutionObject(null)
After execution we can see status of issue Resolved and Resolution Unresolved. I want to not change the status of issue after validation. If this issue New , this issue must be still New
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does it mean that you want to restric some yours to set resolution on several statuses?
Does it means that resolution is set via issue edit?
Best regards,
Vasiliy
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.
Online 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.