Actually I don't know if this will work. But I have long array with a lot of elements, I need to display all element in order on the body/description of Jira ticket without writing it manually (example: outputs('Compose')?[0] outputs('Compose')?[1] outputs('Compose')?[2]
). Is there anyway to do it using loop? or any other method?
Note: I don't want it to be as paragraph I need it the same as the array listed.
Example array:
[ 'first element', 'second element', 'third element', ]
printed/displayed format:
first element
second element
third element
I tried using loop but don't understand it.
please consider that I'm new to the Logic App or any other technologies with the same idea
CodePudding user response:
I'm going to assume that what you end up putting together needs to be separated by a html line break (i.e. <br>
) but if this not the case then you can make it whatever you want.
I've just tried to mimic what you provided with this basic flow ...
You can see the first step is a compose for your array and the second step is initialising a string variable using the join
expression. This concatenates all strings within the array together separated by the HTML line break.
join(outputs('Compose'), '<br>')
Result
CodePudding user response:
There are ways which we can perform data operations such as:
- Line by line
- Spaces
Option 1: Line by line
Firstly, I have initialized a variable as below:
Then used Join (Data Operations) as below:
(here I just clicked Enter in Join with )
Output:
Code view:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "emo",
"type": "array",
"value": [
"rithwik",
"bojja",
"chotu"
]
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Join": {
"inputs": {
"from": "@variables('emo')",
"joinWith": "\n"
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "Join"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
So now you can use the output of Join(body('Join')
Option 2: Spaces
If you keep space in Join you will get ouput as below:
Output:
Code view:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "emo",
"type": "array",
"value": [
"rithwik",
"bojja",
"chotu"
]
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Join": {
"inputs": {
"from": "@variables('emo')",
"joinWith": " "
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "Join"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}