Estimate time not updated

yaniv_shoshani November 8, 2015

Hi

we wrote a script for updating original estimate field (under time tracking) using the setOriginalEstimate() function.

when we execute the script the field is updated but after we hit the refresh button for a few time the data is disappear and the data is set to zero( '0')

what may cause this?

 

thanks

2 answers

0 votes
A November 8, 2015

You can't set values on the issue in a script field... you should do this using a listener. Maybe you can explain the use case a little bit more?

yaniv_shoshani November 10, 2015

Hi, We want to sum up original & remaining estimation as well as time spent from subtasks and set the values to their parent's Epic . in order to do that, we are calling two JQL querys. Here is the full script: import com.atlassian.jira.bc.issue.search.SearchService import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.web.bean.PagerFilter import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.IssueManager import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.event.issue.IssueEvent def componentManager = ComponentManager.getInstance() def issue = ComponentAccessor.getIssueManager().getIssueObject("TEST-52")// without this line, the script return errors for the last 5 rows and with it the script works for the specified key def x = issue.getKey() def jqlQuery = '"Epic Link" =' +x def original=0; def spent=0; def remaining = 0; getFilterResult (jqlQuery,log).each{ Issue Foundstory -> def jqlQuery2 = '"Parent" =' +Foundstory.getKey() getFilterResult (jqlQuery2,log).each{ Issue Foundissue -> if(Foundissue.getOriginalEstimate()!=null){ original = original + Foundissue.getOriginalEstimate(); } if(Foundissue.timeSpent!=null){ spent = spent + Foundissue.timeSpent; } if(Foundissue.getEstimate()!=null){ remaining = remaining + Foundissue.getEstimate(); } }} def usera = ComponentAccessor.getUserUtil().getUserByName("Pazg"); List<Issue> getFilterResult(String jqlSearch, log) { def searchService = ComponentAccessor.getComponent(SearchService.class); def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser() List<Issue> issues = null def parseResult = searchService.parseQuery(user, jqlSearch); if (parseResult.isValid()) { def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter()) issues = searchResult.issues } } long orig=original.longValue() long spt=spent.longValue() long remain=remaining.longValue() issue.setOriginalEstimate(orig) issue.timeSpent = spt; issue.setEstimate(remain); ComponentAccessor.getIssueManager().updateIssue(usera, issue, EventDispatchOption.ISSUE_UPDATED, false) issue.store() return null;

0 votes
GabrielleJ
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.
November 8, 2015

I think it depends on what your script is.

I guess it is a scripted field? If yes, Note that this field is NOT static. It will re-evaluate its own value again everytime it is displayed. So there is a possibility that the value will not be the same as before. If no, Let us know what your script looks like so maybe we can help.

yaniv_shoshani November 8, 2015

Hi Gabrielle 

It is indeed a scripted field but the data seems to change even though the issues data remain unchanged

thanks

GabrielleJ
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.
November 9, 2015

What does your scripted field looks like?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events