expand not working when using issueFunction in workLogged

Hello,

I am using a custom field called "team" mapped to "customfield_10013". The below query return the field per ticket as expected.

/rest/api/2/search?jql=assignee = admin&expand=customfield_10013

However when using the provided by script runner addon " issueFunction in workLogged" the custom field is not returned any longer.

/rest/api/2/search?jql=issueFunction in workLogged('by admin on 2014/03/11')&fields=worklog&expand=customfield_10013

Is this a bug or an expected behavior? How can I get both the worklog and the custom fields?

Thanks,

- Nestor

6 answers

0 vote

Does retrieving worklogs work with other queries?

May be escaping issue? Can't think of any reason why it would work with a simple query and not with a function.

Worklog works. I have edited the question "the custom field is not returned any longer" when using "issueFunction in workLogged"

0 vote

This worked fine for me...the custom field is shown in the output regardless of whether I do expand or not. I'm not sure that's even a valid value for "expand".

The two urls I tested were:

http://localhost:8080/jira/rest/api/2/search?jql=issueFunction%20in%20workLogged(%22by%20admin%22)

http://localhost:8080/jira/rest/api/2/search?jql=key=JRA-1826

with "expand=customfield_12345" I got the same results.

The issue is related to the inclusion of "fields=worklog". When used, the custom fields do not show up. You are right custom fields show up even without using expand (which is mandatory in queries not using the plugin functions) and in reality that would be enough for me if I would actually get the time spent at the day of the query. However the "timespent" field returns the total worklog as you can se below:

Request:

/rest/api/2/search?jql=issueFunction in workLogged('by admin on 2014/03/11')

Response:

...

timespent: 3600

...

customfield_10013: {

self: "/rest/api/2/customFieldOption/10082",

value: "Front-End",

id: "10082"

},

The second call has no effect indeed as per the previous conclusion about expand not needed.

Request:

/rest/api/2/search?jql=issueFunction in workLogged('by admin on 2014/03/11')&expand=customfield_10013

Response:

...

timespent: 3600,

...

{

self: "/rest/api/2/customFieldOption/10082",

value: "Front-End",

id: "10082"

},

The third call will remove the custom field however the timeSpent does reflect exactly the worklog for the date in the query. Now "timespent" becomes "timeSpentSeconds". Unfortunately the custom field does not show up.

Request:

/rest/api/2/search?jql=issueFunction in workLogged('by admin on 2014/03/11')&fields=worklog

Response:

...

timeSpent: "30m",

timeSpentSeconds: 3600,

...

customfield_10013 does not show up

The fourth call demonstrates once again that adding the expand field has no effect.

Request:

/rest/api/2/search?jql=issueFunction in workLogged('by admin on 2014/03/11')&fields=worklog&expand=customfield_10013

Response:

timeSpent: "30m",

timeSpentSeconds: 3600,

...

customfield_10013 does not show up

Can you summarise the problem, ie give me one url that is not working as expected, and also demonstrate that it works properly with some other function, eg assignee = currentUser()?

Because I don't see where this would be a problem in my code...

1. Locate a ticket for which you have logged time in two different dates. Let us assume 30m(1800sec) in 2014/03/10 and 30m(1800sec) in 2014/03/11. The total so far is 1hr(3600sec).

2. The below query should return in a field (timeSpent?) *just* 30m however it just returns one field (timespent) related to worklog (the total of 3600). Note the difference between timeSpent (uses h,m instead of plain seconds) and timespent (number of seconds).

/rest/api/2/search?jql=issueFunction in workLogged('by admin on 2014/03/11')

I think a better terminology could be to use timeSpent as the time related to the constraints given in the query (30m) while totalTimeSpent should relate to the total amount of time spent in the ticket (1h). I also believe that timeSpentInSeconds (1800) and totalTimeSpentInSeconds (3600) are more useful from an API perspective.

Thank you!

- Nestor

Do you have a script field called timespent or timeSpent or similar?

The jql function has not control over what fields are returned. I'm struggling to think this could be an issue with the workLogged function, but I could believe there is a problem with your scripted fields...

Hi Jamie,

I can confirm we are not using custom scripts.

Are you saying that workLogged function is not responsive for the addition of the fields tineSpent, timespent, timeSpentSeconds? Those fields appear thanks to the use of the function.

Did you follow my two steps? Don't you see in your system that calling the below does not obtain the time spent on a ticket in a particular date range specified in the JQL, but instead it contains the total time spent on the issue:

/rest/api/2/search?jql=issueFunction in workLogged('by admin on 2014/03/11')

Thank you very much for folloing up on this,

- Nestor

Hi Jamie should I open then a bug for tracking puproses?

Thanks!

- Nestor

You could do, but you need to give the steps so I can reproduce on a clean database. From everything you've said so far, it doesn't seem like anything to do with my plugin, or if it is looks like there's nothing I can do about it.

Hi Jamie, hopefully you will be able to replicate in your system. Please let us follow up on https://jamieechlin.atlassian.net/browse/GRV-437. Thanks! - Nestor

Hi Jamie, I have updated my report above. There is indeed a problem as you can see. Should this be considered a bug?

Thanks!

- Nestor

1. Locate a ticket for which you have logged time in two different dates. Let us assume 30m(1800sec) in 2014/03/10 and 30m(1800sec) in 2014/03/11. The total so far is 1hr(3600sec).

2. The below query should return in a field (timeSpent?) *just* 30m however it just return one field (timespent) releated to worklog (the total = 3600). Note the difference between timeSpent and timespent.

/rest/api/2/search?jql=issueFunction in workLogged('by admin on 2014/03/11')

I think a better terminology could be to use timeSpent as the time related to the constraints given in the query (30m) while totalTimeSpent should relate to the total amount of time spent in the ticket (1h). I also believe that timeSpentInSeconds (1800) and totalTimeSpentInSeconds (3600) are more useful from an API perspective.

Thank you!

- Nestor

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

839 views 2 9
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