I need a few lookups to create lists to put into a slack message. Most are single line so I can store them in a variable like so:
Delivered by: {{#lookupIssues.assignee.displayName.distinct}}{{.}}{{^last}}, {{/}}{{/}}
However, for one I want it displayed as a list. I've tried the following, but it still appears as a single line with the \n displayed literally:
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}"\n"{{/}}{{/}}
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}\n{{/}}{{/}}
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}"\\n"{{/}}{{/}}
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}\\n{{/}}{{/}}
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}\\\n{{/}}{{/}}
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}//n{{/}}{{/}}
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}\r\n{{/}}{{/}}
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}"\r\n"{{/}}{{/}}
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}%n{{/}}{{/}}
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}"%n"{{/}}{{/}}
What is the magic trick that would make this appear as a flat text, multi-line list?
While I'd love to be able to do this in one step, I have a work around that can achieve the result in 2 steps:
Var listOstuff
{{#lookupIssues}}- {{url}} | {{summary}} {{^last}}@@{{/}}{{/}}
var splitVar
{{listOstuff.replaceAll("@@", "\n")}}
Pretty annoying that "\n" didn't work in the first variable, but at least I have the outcome I required - a single var that will produce multiple lines when used in a slack, email, description, etc.
How does the result look like in slack. How do you send it to slack? I am trying to export issue key from jira to confluence. and i also need a variable that is able to create a list.
I do the export via Web request.
When i export the var List0stuff, it doesent break line
with car splitVar, i dont get anything in confluence (empty)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not sure about how this appears in confluence. I do have a rule that creates a Confluence page, but it populates it with a Jira filter using the Custom Data field in the web send request. I have the following.
Note that the space key is not the acronym, but the DB ID. I can't remember how to find that right now though
{
"type":"page",
"title":"{{confluencePageTitle}}",
"space":{"key":"~638fe4c377ded224b342bebd"},
"ancestors":[
{
"id":"{{confluenceParentPageID}}",
"type":"page"
}
],
"body":{
"storage":{
"value":"<h3>This table is the default Confluence macro based on a Jira JQL query</h3><ac:structured-macro ac:name=\"jira\" ac:schema-version=\"2\" data-layout=\"full-width\" ac:local-id=\"47b7a423-20c9-46d4-8aeb-3b958138bc0a\" ac:macro-id=\"030ad535-7abe-44af-b31a-917e05f2e9c8\"><ac:parameter ac:name=\"columns\">issuekey,issuetype,priority,summary,status,resolution,reporter,issuelinks</ac:parameter><ac:parameter ac:name=\"maximumIssues\">40</ac:parameter><ac:parameter ac:name=\"jqlQuery\">fixVersion = {{version.name}} AND resolution is not EMPTY</ac:parameter></ac:structured-macro>",
"representation": "storage"}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To answer the Slack part of your question. I first set up a Jira app in Slack admin config. That allows me to create webhook URLs for each Slack channel (button in slack says "Reinstall to Workspace" to add new ones).
That URL is needed in the A4J action. IN the case below I put the webhook URL into a smart variable (I have logic in the rule to set a Slack channel based on a Jira issue field).
Slack does not render HTML, but you can use limited text markup, like the emoji's. Basically, what you can type into a Slack chat, you can put into the Message field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Howdy @Dave Furlani ,
The trick may be to actually use line breaks in the lookupIssues loop. Here's an example of a list populating from the lookup results. Granted it also formats as links, but it should work the same with non-linked text:
These issues match the JQL subscription:
{{#lookupIssues}}
• <{{url}}|*{{key}}* {{summary}}>
{{/}}
And the output in Slack comes out like this:
The magic is just getting the {{/}} loop closure the next line down from the end of the text you want to print. No \n involved!
Cheers,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Daniel Eads
That works as you say in multi-line text fields such as an email body, issue description or slack message.
My problem is that I'm trying to create a smart variable that will produce multiple lines when used. Smart variables only offer a single line to create their contents in, so I can't add in new lines in the way you describe.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, the variables are single-line only. Without seeing the full details of what you're trying to populate, my suggestion would be to try and refactor the rule so that the actions where the multi-line fields might be used can be iterated over. Whatever might be going into the variable, try to do it in the email/issue update/slack actions instead. This might lead to having the same body in a couple places instead of calling the variable, but should allow for multi-line formatting in those places.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The reason I needed to load the multi-line results into a variable was because the slack message output needs multiple lookups in the rule to populate with all the data required. Because each lookup replaces the data of any previous lookup, I need to hold it in a variable until the final step where the slack is sent
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Adding .concat("\n") worked for me when sending messages to a Slack channel.
Example:
{{#authorInactivePages}}
{{title}} at {{url}} was last updated on {{dateLastUpdated.shortDate.concat("\n")}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried adding \\ characters?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good thinking @Tuncay SenturkI had not.
I have now, and sadly that didn't work either.
I'll update the original post so future people don't have to read down this far.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"\\" totally works as a new line.
First line \\ {{#lookupIssues}} [~accountId:{{assignee.accountId}}] {{key}} \\ {{/}] Last line.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Dave Furlani You can try: join("\n") or concat("\n") at the end of the final variable in your string
{{#lookupIssues}}- {{url}} | {{summary.concat("\n")}}{{/}}
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.