allComments() function doesn't work

Issue #491 resolved
Alejandro Villalobos [atSistemas] created an issue

Hi, I'm trying to display all comments for the current issue in the email body.

I tried to use this expresions:

%{allComments()}
allComments()
allComments(%{00015})
{allComments(%{00015})}

where %{00015} is the value for the issue key

Are this possible? Or this functions are only available in the 'Conditional execution' block? In addition, the documentation should be updated in order to explain more deeply the functions usage.

Comments (14)

  1. Fidel Castro Armario repo owner

    Hi Alejandro,

    Subject and body of the email use only basic parsing mode, so you only can insert field codes, but can't use function.

    Anyway, there is a way to do it: you can previously compose your message using advanced parsing mode using "Copy a parsed text to a field" post-function and store the body composition at Ephemeral string 1. Then you simply have to write the field code in the body field of Send an email post-function.

    You can also use "Copy a parsed text to a field" post-function to compose only the part of the body related with comments.

    Assuming that you are using HTML format for the body, you can get all the comments in Ephemeral string 1 using "Copy a parsed text to a field" post-function with the following configuration: Captura de pantalla 2017-01-30 a las 9.53.06.png

    Text to be parsed is:

    replaceAll(toString(textOnStringList(allComments(), "<p>" + ^% + "</p>")), "</p>,", "</p>") 
    

    Function toString() converts the string list returned by textOnStringList() into a comma separated list of strings, and replaceAll() is used to remove the commas.

    In order to simplify use cases like this one, next version of the plugin will provide a function toString(string, separator) where you will be able to specify no separator, and this way replaceAll() will not be needed.

  2. Alejandro Villalobos [atSistemas] reporter

    Thanks for the workaround, Ephemeral string 1 should be a new custom field that I will create on the system right?

    Obviously non-visible for the current project to do the magic..

  3. Fidel Castro Armario repo owner

    Ephemeral string 1 to Ephemeral string 5 are virtual fields provided by JIRA Workflow Toolbox. They are not persistent, only remaining in memory. They will be automatically erased after each transition.

    They are intended to be used to pass temporary values from a post-function to another one.

  4. Alejandro Villalobos [atSistemas] reporter

    Thanks, it works like a charm.

    However I would like to display the Author as well, something like this:

    <p> Author 1 <br/> Lorem ipsum... </p>

    <p> Author 2 <br/> Lorem ipsum... </p>

    <p> Author 1 <br/> Lorem ipsum again... </p>

    Could you help me with this format?

  5. Fidel Castro Armario repo owner

    You can use this expression:

    replaceAll(toString(textOnStringList(allComments(), "<p>" + nthElement(allCommenters(), indexOf(^%, allComments())) + "<br>" + ^% + "</p>")), "</p>,", "</p>")
    

    I warn you that this solution fails when a comment is edited, since allCommenters() returns comment creators and editors mixed together.

    I will study the modifications to add in next version of the plugin to correctly support this use case, and simplify its implementation.

  6. Alejandro Villalobos [atSistemas] reporter

    Thank you so much,... I will use the previous one instead because edited comments are a daily basis task

  7. Fidel Castro Armario repo owner

    Hi Alejandro,

    Version 2.2.30 has just been released. This new version provides function allCommentCreators() that make it possible to implement your requirements using the following expression:

    toString(textOnStringList(allComments(), "<p>" + nthElement(allCommentCreators(), indexOf(^%, allComments())) + "<br>" + ^% + "</p>"), "")
    
  8. Alejandro Villalobos [atSistemas] reporter

    By the way, we wanted to do something similiar with issuelinks of type XXX for example:

    IssueLink clones:

    <p>ISS-3 Lorem ipsum</p>

    <p>ISS-57 Error linked</p>

    <p>ISS-125 Recurrent Error </p>

    Any workaround?

  9. Fidel Castro Armario repo owner

    You can set Ephemeral string 2 using "Copy a parsed text to a field" post-function in advanced parsing mode with the following text expression:

    toString(textOnIssueList(linkedIssues(), "<p>" + ^%{00015} + " " + ^%{00000} + "</p>"), "")
    
  10. Log in to comment