We have a step in our workflow to send an email containing various details to a distribution list. We achieved this by using the Send Email built in function from scriptrunner, but have found that when the description field on an issue contains \\ then the email step fails to trigger. I have tried to add the below, but I receive the error: Property '$stringUtils' not found.
Just wondering if anyone can help me to strip out the \\ or replace them so the email will still work?
<tr>
<td>Description:</td>
<td>${$stringUtils.replaceEach(issue.description, "\\", "")}</td>
</tr>
Thanks
Community moderators have prevented the ability to post new answers.
I think it's probably a bug that a single backslash causes an error. Note that two backslashes is a new line in wiki markup.
You can do by using the wiki renderer:
<% def rendererManager = com.atlassian.jira.component.ComponentAccessor.getComponent( com.atlassian.jira.issue.RendererManager.class) def fieldLayoutItem = com.atlassian.jira.component.ComponentAccessor.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem("description") def renderer = rendererManager.getRendererForField(fieldLayoutItem) def desc = renderer.render(issue.description, null) out << desc %>
but not ideal, I'll raise an issue: https://jamieechlin.atlassian.net/browse/GRV-812
have you tried using replaceAll
in groovy?
I think it would be something like this and I believe you have to escape the backslashes.
issue.description?.replaceAll("\\\\", "")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, Jeff I tried <tr> <td>Description:</td> <td>${issue.description?.replaceAll("\\\\", "comment")}</td> </tr> It is not giving an error but now, and it successfully sends the email (which is progress), however I am just receiving an empty row on the email. I would have expected (or hoped) it would simple remove the \\?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
btw - I tried both ${issue.description?.replaceAll("\\\\", "")} and ${issue.description?.replaceAll("\\\\", "comment")} to see if the empty row would populate with 'comment'... but it did not.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
weird it worked for me using the script console. import com.atlassian.jira.component.ComponentAccessor; issue = ComponentAccessor.getIssueManager().getIssueObject("ZAA-2"); issue.description?.toString().replaceAll("\\\\", "comment") produced (it added an extra "comment" but it did work.. probably a better way to escape it or use regex)! I edited this description didn't I??????/ commentcomment what is this commentcomment it worked for me either way but maybe try ${issue.description?.toString().replaceAll("\\\\", "comment")} Have you tried logging the before and after to see what it is doing? Maybe taking the
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jeff, I tried:
${issue.description?.toString().replaceAll("\\\\", "")}
But I always return an empty cell for Description. Even when there are no backslashes contained in the text. The above returns no data on the email body.
I'm completely stuck
Environment: | Test |
Reason for request: | Data-Fix |
Summary: | test only - pls ignore |
Description: | |
Requester: | James Porter:1 |
Promoter: | James Porter(james) |
Downtime: | none |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've done further testing and the problem isn't related to double backslash...(\\) - I can see now that if there is a single backslash - \, the email will also fail to fire.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
did you log the before and after? For all we know this is a an email/HTML issue... which I actually suspect is your problem. You may have to make this HTML safe with some encoding. Since users can log novels in the description, I don't include it in any custom emails.. if they want it, they can click the link! I once used this to render comments.. but I can't remember if this rendered HTML as wiki markep or the other way around? I haven't touched that in years though and never put it into production. String LastComment = componentManager.getCommentManager().getComments(issue).last()?.body; LastComment = componentManager.getInstance().getRendererManager().getRenderedContent("atlassian-wiki-renderer", LastComment.toString(), issue.issueRenderContext); Time for some debug statements to figure out where the problem is!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.