Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Groovy postfunction

John Peterson April 11, 2018

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

4 answers

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2018

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

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 11, 2018

Better create a validator. If resolution is entered then throw a error. I think it is a better solution.

John Peterson April 11, 2018

It's not possible to do It using Groovy?

0 votes
John Peterson April 11, 2018

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 

0 votes
Vasiliy Zverev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 11, 2018

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

John Peterson April 11, 2018

Yes 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events