Copy content of KCF Interval to Original Estimate

Hi,

When I create an issue I have replaced the time tracking with an Interval Custom Field called 'Proposed Estimate'. The intention is that a user would create the issue with a proposed time and the PM would approve it. When the Issue is approved I want to copy the value from 'Propsed Estimate' in to 'Original Estimae' and 'Remaining Estimate'. I have a number of plugins providing me with these possiblilities but they all seem to have an issue that I can't copy a interval in to a number field.

Is there a way of getting the numerical value from the Interval Field? I noticed somthing about SIL in conjunction with Interval Fields, could this help?

Are there any other solutions to this?

Thanks

2 answers

1 accepted

This widget could not be displayed.

This comment from Radu Dumitriu

was my solution, here is the scipt I created in the end...

import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.project.Project
import org.apache.log4j.Category

def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.setLevel(org.apache.log4j.Level.DEBUG)
log.info("Starting GroovyScript MoveProposedEstToOrigEstimate")

MutableIssue issue = issue
Project project = issue.getProjectObject()
log.debug("Working with Issue " + issue.getKey() + " ("+project.getName()+")")
ComponentManager componentManager = ComponentManager.getInstance();
CustomField proposedEstimateCustomField = componentManager.getCustomFieldManager().getCustomFieldObjectByName("Proposed Estimate")
CustomField budgetedEstimateCustomField = componentManager.getCustomFieldManager().getCustomFieldObjectByName("Budgeted Estimate")
def proposedEstimate = issue.getCustomFieldValue(proposedEstimateCustomField)
log.debug("Proposed estimate is "+proposedEstimate)
issue.setOriginalEstimate(proposedEstimate.round())
issue.setEstimate(proposedEstimate.round())
issue.setCustomFieldValue(budgetedEstimateCustomField,proposedEstimate)
budgetedEstimateCustomField.
issue.store()
log.debug("New original estimate is "+issue.getOriginalEstimate())
log.debug("New remaining estimate is "+issue.getEstimate())
log.debug("New budgeted estimate is "+issue.getCustomFieldValue(budgetedEstimateCustomField))

Happy to be of any help ! That was easy, wasn't it ?

Hi Radu I used above script to copy value from custom field(number) to original estimate, it is copying, but shows in seconds, how to convert that to hours, thanks for your help Raju

This widget could not be displayed.

The interval custom field from KCF is in fact a number custom field that is displayed differently, so the value stored for it in the database is numeric (in seconds). However, it's designed so that its string representation uses the interval format ("1d 2h"). What plugins are you trying to use to accomplish this ?

Thanks for your quick response;

I have a few plugins for workflow transitions

  • JIRA Suite Utilities
  • JIRA Workflow Toolbox
  • JIRA Misc Workflow Extensions

From these I have tried to use the following post functions for this...

  • Copy Value From Field to Field - Copies the value(s) of one field to another field. Can copy the value of the field before it was changed on the transition's screen.'
  • Set a field from a set of rules based on regular expressions - Sets a field from a set of rules based on regular expressions.

The first one at least let me configure the post function, when I tested it though it gave an error saving somthing along the lines of invalid workflow contact your admin.

The second one indicated the error in the workflow view, gave an XML error but I believe the real error is to do with trying to move an invalid value type in to the original estimate.

If you know of a valid post function to achieve this it would be great!

Normally we'll use that to do cross-sales with JJupin or Blitz Actions =) LOL

The idea is very simple, as my colleague told you, the stored value is the interval, in seconds, but this is a double value, from what I see in the code (this is to provide better support for one of the above plugins ).

The reason it doesn't work is that you will need to transform the value provided by the CF into something meaningful for your destination CF, i.e. you need to call something like (pseudocode):

Double val = (Double) issue.getCustomFieldValue(cfDesc);

issue.setOriginalEstimate(val.longValue());

//save the issue.

For that, I may suggest Jamie's Script Runner (which is free). Of course (cause I cannot skip over the cross-sales thing :) ), in JJupin the above is done like this:

originalEstimate = customfield_12345;

or:

originalEstimate = #{Proposed Estimate};

Edit: Let us know if you have issues with that (email us if you need more info, etc ...)

Thanks for the help, I have the script runner installed and am currently writing some scripts for it. I figured that I would have to go down this route. Will be in touch if I have any questions!

Cheers!

I suspect that my main issue was caused by the Original Estimate expecting a long and the Interval Csutom Field containing a double.

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...

533 views 3 19
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