Hello everyone
Actually I am trying to change my original estimate values based on custom field value Like if we have 10H in original estimate and we enter 50 in number field it will subtract the 50% from the original estimate then it become 5H when specific transit happen for that I bulid a post function in JMWE but it give error
{%- if issue.fields.customfield_10185 is defined and issue.fields.timeoriginalestimate is defined -%}
{%- set customFieldValue = issue.fields.customfield_10185.value %}
{%- set originalEstimate = issue.fields.timeoriginalestimate.value %}
{%- set percent = customFieldValue / 100 %}
{%- set newEstimateSeconds = originalEstimate - (originalEstimate * percent) %}
{%- set newEstimateHours = newEstimateSeconds / 3600 %}
{%- set update_params = {"timeoriginalestimate": {"value": newEstimateHours}}-%}
{{- issue.updateIssue(update_params) -}}
{%- endif -%}
Following is the error:
(string) [Line 7, Column 23] Error: Unable to call `issue["updateIssue"]`, which is undefined or falsey
Hi @Umar Maroof ,
Build-your-own post functions are meant to use the Jira REST API directly to make changes to Jira. You cannot update fields the way you did.
Also, there are a few errors in your script. For example, if customfield_10185 is a Number field, its value is directly issue.fields.customfield_10185, not issue.fields.customfield_10185.value (which would be for a Select-type field). Same for timeoriginalestimate. You can see all this on the "Issue Fields" help tab below the editor.
Furthermore, the timeoriginalestimate field expects a number of seconds, not hours.
Instead, you should use a Set Issue Fields post function, select the Original Estimate as the field to set, and for the value use the following script:
{%- if issue.fields.customfield_10185 is defined and issue.fields.timeoriginalestimate is defined -%}
{%- set customFieldValue = issue.fields.customfield_10185 -%}
{%- set originalEstimate = issue.fields.timeoriginalestimate -%}
{%- set percent = customFieldValue / 100 -%}
{%- set newEstimateSeconds = originalEstimate - (originalEstimate * percent) -%}
{{- newEstimateSeconds -}}
{%- endif -%}
and you should select the "Ignore empty value" option to avoid modifying the Original Estimate if one of the fields is empty.
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.