how to convert original estimate to number

Karim Belhadj December 28, 2018

I have a formula that i must multiply a custom field number by the original estimate , i find problem because the original estimate have not the number type 

 

so i need to convert it.

 

Regards

 

2 answers

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 28, 2018

The original estimate is not a "duration", it's a number.  Measured in milliseconds, so if you want it in minutes, you need to convert it with

issue.getOriginalEstimate() / 60,000

For hours, divide again by 60.  For days/weeks though, again divide, but remember to take into account your time tracking settings (1 day is 8 hours, not 24)

Note - that call above should return a long number if I remember right, but I think it's ok to multiply a long with a double?

Assia Touati June 12, 2020

Hi, how to do the opposite of that calculation ? 

I suppose that i have a number, and i want to put it in the original estimate field 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 12, 2020

How are you putting it in?  Code?  Typing?  REST call?

Assia Touati June 12, 2020

using the smart values

{{#math}}{{issue.customField_10061}}+{{issue.customField_10062}}+{{issue.customField_10063}}+{{issue.customField_10079}}{{/math}}

 

it works when the sum is an integer, but doesnt when it's real 

ex : 1 + 1 + 3 + 2   shows "1d" in the original estimate 

or 1.5 + 1.5 + 2 + 1 shows 6h 

but when i put 1.5 + 1 + 2 + 3 the rule doesnt execute 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 12, 2020

I don't use smart values, but that looks like a bug in it.

Assia Touati June 15, 2020

I tried to use JSON,

here is my script 

{
"fields": {
"timetracking": {
"originalEstimate": "issue.customField_10087"

}
}
}

 

where the customfield 10087 is a text field and i've entered as an example : "1h 30m" , but still doesnt work :s 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 15, 2020

Could you enter it in milliseconds, as that's the storage format?

Assia Touati June 16, 2020

4.5 gives me this result when i do the conversion to milis 

image.png

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2020

Ah, the API is not listening in milliseconds.  Have you tried plain 4.5?

Assia Touati June 16, 2020

What do you mean by plain 4.5 ?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2020

Literally feed it a number.  The rest API only takes numeric data (I thought it was milliseconds because that's what I see in code elsewhere).  4.5 is likely to be 4.5 hours, but you'll see that when you look again at the issue.  Whatever unit it is expecting, it will be consistent.

Assia Touati June 16, 2020

when i add 0.5 to 4.5, it's working and showing 5hours, also if i add 2.5 to 4.5 it shows 1d (as i've set 1day=7hours in the Timetracking settings). 

However, i want to have the 4.5 or whateaver (1.75 hours ...etc.) . But it's frustrating because it's not working! 

Is it a bug ??? do i have to report it ? 

Thank you again for you answers, fixing this problem will have an impact in our Jira projects. 

Like Luis Alejandro De Peña likes this
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2020

Are you saying decimal values are not working?

Assia Touati June 16, 2020

Yes exactly. 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2020

That is very odd, it works for me.

I think, yes, you may need to report it as a bug.

Assia Touati June 16, 2020

Could you send me a screenshot of how did you manage to make it works ???

Thank you 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2020

I'm not doing anything differently to you.  Hitting the rest endpoint with a curl backed json payload.

Assia Touati June 16, 2020

I'm i doing something wrong in this code ??? 

 

{
"fields": {
"timetracking": {
"originalEstimate": "issue.customField_10061+issue.customField_10062+issue.customField_10063+issue.customField_10079"

}
}
}

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2020

Yes, you need to give it a number, not a string of custom field names.

Assia Touati June 17, 2020

could you please give me an example ? 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 17, 2020

{
"fields": {
"timetracking": {
"originalEstimate": "4.5"}
}
}

Works for me.

Assia Touati June 17, 2020

Me too,  but is there a way To parse the value of a cutom field.  ???

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 17, 2020

Yes, your code will need to ask Jira for the data for the fields, do the calculations you need and then send back a number.

Assia Touati June 17, 2020

Ok, i'll try this, but do you have any documentation ? i'm not very familiar with JSON in JIRA, just starting. 

azade bagheri January 23, 2021

Hello Assia,

can you solve this issues?

i need this feature and don't know how to configure it.

can you help me if resolved it?

 

thank's

Azadeh

Luis Alejandro De Peña May 19, 2021

I'm having the same issue ,,,, any help in this regard? When my custom field has a value of 4.5 it calculates as 45h! (number field and I pass the value as smart value with "h").

Thomas Wohlwend August 19, 2021

you may want to try 4,5

Jan Stähle March 21, 2023

Is there any solution to the problem described above that entering 4.5 leads to 45h yet? 
I am having the same issue when populating the field via Jira Automation with the following formula: 

{{#=}}{{triggerissue.timeoriginalestimate}} * 0.85 / 3600 {{/}}

With the input parameter is 10h, I would expect to see 8.5h - what we get is 85h - when changing the 0.85 to a one digit decimal like 0.8 or 0.9 it gives me 8h, 9h respectively. 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 21, 2023

It's the same as given before.

0 votes
Rajesh Ramankutty December 28, 2018

Can you Give Some Example cant able to understand properly

Karim Belhadj December 28, 2018

@Rajesh Ramankutty 

my formula is 

 

result = Original estimation * double(avp) 

original estimation type is duration 

avp is a custom field with type double.

 

Regards

Suggest an answer

Log in or Sign up to answer