Is it possible to copy numeric field value using JIRA automation?

Mykola Makhin April 7, 2023

I'm trying to create an automation that would set custom field "Story points number" to the value of built-in field "Estimate[Number]", using code like this:

{
"fields": {
"Story point estimate": {{issue.Estimate.asNumber}}
}
}

But it doesn't work.

I've tried multiple variations, e.g.

{
"fields": {
"Story point estimate": {"id":"{{issue.Estimate[Number].asNumber}}"}
}
}

But always end up with JSON parsing error ("Error while parsing additional fields. Not valid JSON.") or with an error saying value is not a number ("ES-341 (Specify a number for the custom field (below 100,000,000,000,000) (customfield_10016))")

I've tried different variations with and without [Number] part in field name, using {"id":"{{issue.Estimate.asNumber}}"} etc - nothing worked.

I'm also not sure why "Story point estimate" is a custom field - I didn't create it, it appeared after I enabled "Estimates" feature.

What I actually need to do is to copy story point estimates from existing "Estimate" field to this new field/

1 answer

1 accepted

0 votes
Answer accepted
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 7, 2023
Mykola Makhin April 7, 2023

Not sure what do you mean by "use smart values" here - I already tried "{{issue.Estimate[Number].asNumber}}"

It didn't work.

How exactly should I use these smart values in this case?

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 7, 2023

Sorry @Mykola Makhin didn't see that you had already used smart values :(

Are you on CMP or TMP?

Mykola Makhin April 7, 2023

TMP

Also I found out that Estimate is a custom field too - by sorting on it. It's cf[10067], while Story point estimate is a cf[10016].

So basically I need to copy value of one numeric custom field into another numeric custom field.

But, code like this:

{
"fields": {
"Story point estimate": {"id":"{{issue.[10067].value}}"}
}
}

results in error (Specify a number for the custom field (below 100,000,000,000,000) (customfield_10016))

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 7, 2023

On my instance story points estimate is going by a customfield number.

rest.png

 

It worked for me like this:

{
"fields": {
"customfield_10016": 50
}
}

And hold on, I'll give you the proper smart value as well. 

Mykola Makhin April 7, 2023

It'll work for constant for sure. But what I really need is not a constant, but a value of another numeric custom field.

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 7, 2023
{
"fields": {
"customfield_10016": {{issue.fields.Number}}
}
}
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 7, 2023

audit log.png

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 7, 2023

You should add on your rule a log component and see what your smart values return.

Mykola Makhin April 7, 2023

In the 

{{issue.fields.Number}}

what is "fields"? Is that a name of your custom field?

My custom field name is "Estimate", cf[10067].

How do I specify that?

For some reason just putting {{smart field}} without "" results in JSON parsing error, e.g.

{
"fields": {
"Story point estimate": {{issue.Estimate.Number}}
}
}

returns "Error while parsing additional fields. Not valid JSON."

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 7, 2023

"Fields" is another way of getting the values of custom fields. If you take a look at the JSON payload, you'll see that all fields are nested below the "fields". Just type {{issue.fields.Estimate}}

Mykola Makhin April 7, 2023

It's not mentioned in https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#Available-properties , but this way it works.

Thank you!

This worked for me:

{
"fields": {
"Story point estimate": {{issue.fields.Estimate}}
}
}

also this worked too, but I find this option less readable

{
"fields": {
"customfield_10016": {{issue.fields.Estimate}}
}
}

 

Anyhow, thanks again.

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 7, 2023

Good to know that it worked!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events