Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,078
Community Members
 
Community Events
176
Community Groups

Set the time spent based on a custom field

I am trying to integrate Jira with another system and the integration does not allow me to directly integrate the estimates (Original, Remaining, Spent) so I have copied the values into their own custom fields. I can set the original and remaining estimates fine but not the time spent.

I am using JMWE to automate and found a build your own (scripted) post function that allows me to set the time spent to a fixed amount

{{ "/rest/api/2/issue/:issue/worklog" | callJira(verb=("post"), params={"issue":issue.key}, 
body={
"timeSpent": "1h"
}
) | dump(2) }} 

 This works fine except I want to use the value of the custom time spent field {{ issue.fields.customfield_10172 }} to set the value. 

I have tried to insert this as the following but

 "timeSpent": "{{ issue.fields.customfield_10172 }}h" 

"timeSpent": {{ issue.fields.customfield_10172 }}"h"

 
Does anyone have an idea of what to try next?

 

Thanks

1 answer

1 accepted

0 votes
Answer accepted

Hi @Annika ,

What is the problem you are encountering with that attempt?

Also, what is the field type of customfield_10172 ?

Hi David
Thanks for your response - I referenced the wrong custom field in my 

  • 10172 is original estimate (can copy the value into the Jira Original Estimate Field)
  • 10173 is remaining estimate (can copy the value into the Jira Remaining Estimate Field)
  • 10174 is time spent
  • ALL are number fields

If I put the customer field in front of the '' ''

{{ "/rest/api/2/issue/:issue/worklog" | callJira(verb=("post"), params={"issue":issue.key}, 
body={
"timeSpent": {{ issue.fields.customfield_10174 }}"h"
}
) | dump(2) }}

then the error I get is 

(string) [Line 3, Column 16] parseAggregate: expected colon after dict key

And if I put it inside of the ""

{{ "/rest/api/2/issue/:issue/worklog" | callJira(verb=("post"), params={"issue":issue.key}, 
body={
"timeSpent": "{{ issue.fields.customfield_10174 }}h"
}
) | dump(2) }}

then the response is

(string)
  Error: Unexpected response: 400
 Worklog must not be null.
 timeLogged: Invalid time duration entered.

 

 I am sure it is a syntax error and I have tried googling but no luck. 

Hope you can help :)

Hi @Annika 

actually, the correct syntax is:

{{ "/rest/api/2/issue/:issue/worklog" | callJira(verb=("post"), params={"issue":issue.key}, 
body={
"timeSpent": issue.fields.customfield_10174 + "h"
}
) | dump(2) }}

I believe this should work, although there might still be a conversion problem between number and string.

David

That worked perfectly, thanks David 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events