Script Runner Set resolution to fixed after query

Hi,

 

today i created a escalation service in Script runner to update some custom fields.

 

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.link.IssueLink;
def issueLinkManager = ComponentManager.getInstance().getIssueLinkManager()
def customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
def cfEst1 = customFieldManager.getCustomFieldObject("customfield_13233");
def cfEst2 = customFieldManager.getCustomFieldObject("customfield_13234");
def cfEst3 = customFieldManager.getCustomFieldObject("customfield_13235");
def cfEst4 = customFieldManager.getCustomFieldObject("customfield_13236");
def cfEst5 = customFieldManager.getCustomFieldObject("customfield_13237");
def cfEstUncategorized = customFieldManager.getCustomFieldObject("customfield_13238");
def ticket = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_13621");
def changeHolder = new DefaultIssueChangeHolder();
double totalRemaining = 0;
for(IssueLink link in issueLinkManager.getInwardLinks(issue.id)){
 if (link.issueLinkType.name == "Epic Link")
    {
        def linkedIssue = link.sourceObject;
        def total = 0;
        if ( cfEst1 && linkedIssue.getCustomFieldValue(cfEst1)!=null)
          total = total + linkedIssue.getCustomFieldValue(cfEst1);
  if ( cfEst2 && linkedIssue.getCustomFieldValue(cfEst2)!=null)
       total +=  linkedIssue.getCustomFieldValue(cfEst2);   
        if ( cfEst3 && linkedIssue.getCustomFieldValue(cfEst3)!=null)       
           total +=  linkedIssue.getCustomFieldValue(cfEst3);
        if ( cfEst4 && linkedIssue.getCustomFieldValue(cfEst4)!=null)  
           total +=  linkedIssue.getCustomFieldValue(cfEst4);
        if ( cfEst5 && linkedIssue.getCustomFieldValue(cfEst5)!=null)
           total +=  linkedIssue.getCustomFieldValue(cfEst5);
         if ( cfEstUncategorized && linkedIssue.getCustomFieldValue(cfEstUncategorized)!=null)
           total += linkedIssue.getCustomFieldValue(cfEstUncategorized);
  
           totalRemaining += total;
     }
}
if ( issue.issueType.name == "Epic" ){
issue.setCustomFieldValue(ticket, totalRemaining);
ticket.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(ticket), totalRemaining), changeHolder);
}
Now i see when this query has run successfully then the resolution is put to Fixed without doing anything.
The action is all not filled in in the escalation service. Somebody who knows the reason?
kr,

3 answers

1 accepted

This widget could not be displayed.
Vasiliy Zverev Community Champion Mar 29, 2016

I am not sure, but it could be caused by specific of ModifiedValue object.

I usually use IssueManager.updateIssue() for issue update and never get such troubls https://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/IssueManager.html 

This widget could not be displayed.

Hi ,

I tested your recommandation. but it doesn't help

 

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.event.type.EventDispatchOption;
def issueManager = ComponentManager.getInstance().getIssueManager();
def issueLinkManager = ComponentManager.getInstance().getIssueLinkManager()
def customFieldManager = ComponentManager.getInstance().getCustomFieldManager();
def cfEst1 = customFieldManager.getCustomFieldObject("customfield_13233");
def cfEst2 = customFieldManager.getCustomFieldObject("customfield_13234");
def cfEst3 = customFieldManager.getCustomFieldObject("customfield_13235");
def cfEst4 = customFieldManager.getCustomFieldObject("customfield_13236");
def cfEst5 = customFieldManager.getCustomFieldObject("customfield_13237");
def cfEstUncategorized = customFieldManager.getCustomFieldObject("customfield_13238");
def ticket = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_13621");
def user = ComponentAccessor.userUtil.getUserObject("QA");
    def changeHolder = new DefaultIssueChangeHolder();
double totalRemaining = 0;
for(IssueLink link in issueLinkManager.getInwardLinks(issue.id)){
 if (link.issueLinkType.name == "Epic Link")
    {
        def linkedIssue = link.sourceObject;
        def total = 0;
        if ( cfEst1 && linkedIssue.getCustomFieldValue(cfEst1)!=null)
          total = total + linkedIssue.getCustomFieldValue(cfEst1);
  if ( cfEst2 && linkedIssue.getCustomFieldValue(cfEst2)!=null)
       total +=  linkedIssue.getCustomFieldValue(cfEst2);   
        if ( cfEst3 && linkedIssue.getCustomFieldValue(cfEst3)!=null)       
           total +=  linkedIssue.getCustomFieldValue(cfEst3);
        if ( cfEst4 && linkedIssue.getCustomFieldValue(cfEst4)!=null)  
           total +=  linkedIssue.getCustomFieldValue(cfEst4);
        if ( cfEst5 && linkedIssue.getCustomFieldValue(cfEst5)!=null)
           total +=  linkedIssue.getCustomFieldValue(cfEst5);
         if ( cfEstUncategorized && linkedIssue.getCustomFieldValue(cfEstUncategorized)!=null)
           total += linkedIssue.getCustomFieldValue(cfEstUncategorized);
  
           totalRemaining += total;
     }
}
if ( issue.issueType.name == "Epic" ){
issue.setCustomFieldValue(ticket, totalRemaining);
issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED ,false);  
}
kr,
Vasiliy Zverev Community Champion Mar 30, 2016

Perhaps you have some listener on update event which do such update?

This widget could not be displayed.

You're saying there is no action set, but the resolution changes to Fixed, and the issue is not transitioned?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

425 views 3 17
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you