英文:
How to add a New Line in Azure Logic app, concat method?
问题
我试图在Azure逻辑应用中的连接器中添加一个新行,但它只将新行添加为字符串。
我的目标是将我获取的对象数组添加到Word文档中。但它并不会添加一个新行,而是实际添加了字符。
这是我实现的方式。
我已尝试使用<br>和\n。
英文:
I'm trying to add a new line in a concat in azure logic apps. but it only adds the new line as a string instead.
My goal is to add an array of object I get into a word doc. but it doesnt add a new line but actually adds the characters.
This is how I'm implementing this.
I have tried with <br> and \n
答案1
得分: 1
如何在Azure Logic App的concat方法中添加新行?
我在我的环境中进行了复制,并且以下是预期的结果:
设计:
在这里,您可以通过创建一个具有换行符的变量来添加新行,就像在“Initialize variable”操作的值中按Enter键一样。
然后是“concat”语句:
concat(items('For_each')['Firstname'], variables('newline'), items('For_each')['Lastname'], variables('newline'), items('For_each')['Whatname'])
输出:
代码视图:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"Compose": {
"inputs": "@concat(items('For_each')['Firstname'], variables('newline'), items('For_each')['Lastname'], variables('newline'), items('For_each')['Whatname'])",
"runAfter": {},
"type": "Compose"
}
},
"foreach": "@body('Parse_JSON')",
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "Foreach"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "newline",
"type": "string",
"value": "\n"
}
]
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Parse_JSON": {
"inputs": {
"content": "@triggerBody()",
"schema": {
"items": {
"properties": {
"Firstname": {
"type": "string"
},
"Lastname": {
"type": "string"
},
"Whatname": {
"type": "string"
}
},
"required": [
"Firstname",
"Lastname",
"Whatname"
],
"type": "object"
},
"type": "array"
}
},
"runAfter": {},
"type": "ParseJson"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
英文:
>How to add a New Line in Azure Logic app, concat method?
I have reproduced in my environment and below is expected results:
Design:
Here you can add new line by creating a variable with new line like just pressing enter in value(of Initialize variable action).
Then the conact
statement:
concat(items('For_each')['Firstname'],variables('newline'),items('For_each')['Lastname'],variables('newline'),items('For_each')['Whatname'])
Output:
Code view:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"Compose": {
"inputs": "@concat(items('For_each')['Firstname'],variables('newline'),items('For_each')['Lastname'],variables('newline'),items('For_each')['Whatname'])",
"runAfter": {},
"type": "Compose"
}
},
"foreach": "@body('Parse_JSON')",
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "Foreach"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "newline",
"type": "string",
"value": "\n"
}
]
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Parse_JSON": {
"inputs": {
"content": "@triggerBody()",
"schema": {
"items": {
"properties": {
"Firstname": {
"type": "string"
},
"Lastname": {
"type": "string"
},
"Whatname": {
"type": "string"
}
},
"required": [
"Firstname",
"Lastname",
"Whatname"
],
"type": "object"
},
"type": "array"
}
},
"runAfter": {},
"type": "ParseJson"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
答案2
得分: 0
问题出现在使用""\n""连接语句时,在查看工作流程的代码时会添加额外的反斜杠。
我已经创建了一个示例工作流,其中包含以下连接语句并保存了它:
concat(variables('Variable1'), '\n', variables('Variable2'))
然而,当在代码视图中检查工作流时,会插入额外的反斜杠:
concat(variables('variable1'), '\\n', variables('variable2'))
要解决这个问题,您应该在代码视图中删除额外的反斜杠并保存工作流。这将确保一切正常运作。
英文:
The issue arises when using the "\n" concatenation statement, as an extra backslash is added when viewing the code in your workflow.
I have created a sample workflow with the following concatenation statement and saved it:
concat(variables('Variable1'), '\n', variables('Variable2'))
However, when inspecting the workflow in code view, an additional backslash is inserted:
concat(variables('variable1'), '\\n', variables('variable2'))"
To resolve this, you should remove the extra backslash in the code view and save the workflow. This will ensure everything works correctly.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论