Worklog comment import

Hello,

I want worklog comment in my report, how can i get it.
I tried below link, but it is giving only the first word of the worklog comment:
https://docs.eazybi.com/eazybijira/data-import/custom-fields/javascript-calculated-custom-fields#JavaScriptcalculatedcustomfields-Calculatedworklogcustomfield

Could you please help

2 Likes

I’m having the same issue. If you solved this outside of the forum, please update with the solution. @martins.vanags do you have a modified script for this?

Hi @rohit

I just updated our documentation page.
Try this code in your advanced settings:

[jira.customfield_wlcomment]
name = "Worklog Comment"
data_type = "string"
dimension = true
worklog = true
javascript_code = '''
if (worklog.comment) {
worklog.customfield_wlcomment = worklog.comment;
}
else {
  worklog.customfield_wlcomment = "(no comment)"
}
'''

Since this field is already imported as dimension, I recommend unselecting it once for import and import data without it to reset advanced settings. Then it is safe to import data with field selected again.

Martins / eazyBI support

2 Likes

@Larry_Lowe

Please check my last answer to @rohit

Martins / eazyBI support

this Javascript would also add WorklogID in the dimension name, to separate worklogs with the same body text as different members in the dimension (not to group hours automatically for equal worklog comments).

[jira.customfield_wlcomment]
name = "Worklog Comment"
data_type = "string"
dimension = true
worklog = true
javascript_code = '''
if (worklog.comment) {
worklog.customfield_wlcomment = worklog.comment+worklogiID;
}
'''

Martins / eazyBI

Hi @martins.vanags

Would it be possible to import the comments from the comment section using a similar javascript?
image
If it is possible, would the script look like this one?

[jira.customfield_comment]
name = "Comment"
data_type = "string"
dimension = true
worklog = true
javascript_code = '''
if (comments.comment) {
comments.customfield_comment = comments.comment+commentsiID;
}

Thanks,
Marilou

@Marilou
Check this community post:

Martins / eazyBI

1 Like

Thank you so much @martins.vanags !

This Javascript can be used in advanced settings to pre-calulate and later import (from import options page) just the last worklog comment for each issue:

[jira.customfield_lastwlcom]
name = "Last worklog comment"
data_type = "text"
json_fields = ["worklog"]
javascript_code = '''
if (issue.fields.worklog && 
    issue.fields.worklog.worklogs && 
    issue.fields.worklog.worklogs.length > 0)  {
  var lastwlcom = 
      issue.fields.worklog.worklogs[issue.fields.worklog.worklogs.length-1];
  issue.fields.customfield_lastwlcom = lastwlcom.comment;
}
'''

Martins / eazyBI

1 Like

This workaround would let you split too long words by white-spaces for table text wrapping (every 20 non white-space signs)

## Import and modify Custom Field: "Worklog Comment"
[jira.customfield_wlcomment]
name = "Worklog Comment"
data_type = "string"
dimension = true
worklog = true
javascript_code = '''
if (worklog.comment) {
worklog.customfield_wlcomment = worklog.comment.replace(/(\S{20})(?=\S)/g, '$1 '); 
}
else {
worklog.customfield_wlcomment = "(no comment)"
}
'''

Hello! How can I import this as a property? I want to see it like this:

Thanks!

Hi,
Try using this Javascript code to import last comment:

'''
if (issue.fields.worklog && 
    issue.fields.worklog.worklogs && 
    issue.fields.worklog.worklogs.length > 0)  {
  var lastwlcom = 
      issue.fields.worklog.worklogs[issue.fields.worklog.worklogs.length-1];
  issue.fields.customfield_lastwlcom = lastwlcom.comment;
}
'''

Martins / eazyBI

I’m seeing this:

why?

I sent you the JS code earlier.
This would be the full code for last worklog comment in advanced settings:

[jira.customfield_lastwlcom]
name = "Last worklog comment"
data_type = "text"
json_fields = ["worklog"]
javascript_code = '''
if (issue.fields.worklog && 
    issue.fields.worklog.worklogs && 
    issue.fields.worklog.worklogs.length > 0)  {
  var lastwlcom = 
      issue.fields.worklog.worklogs[issue.fields.worklog.worklogs.length-1];
  issue.fields.customfield_lastwlcom = lastwlcom.comment;
}
'''

Martins / eazyBI

Still not seeing it


Unfortunately, worklog field items can not be imported in eazyBI cube if you use Tempo and Jira Cloud combination to log hours in Jira.
That could be the limitation in your use-case.

Martins / eazyBI

Hello Martins, is there any other work around for this use case? The objective is to show a “last update comment” under each project. I don’t know if we need to create a new field in Jira that allows free text input or maybe there is another better solution. Have you faced those request earlier? I saw that there are many requests for comments
image

Thank you!!

Hello Martins, Zane already helped me. Now it is working, thanks.
Here the link were is the documentation > JavaScript calculated custom fields.