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
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?
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;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gabrielle
It is indeed a scripted field but the data seems to change even though the issues data remain unchanged
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What does your scripted field looks like?
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.