0

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.

enter image description here

This is how I'm implementing this.

enter image description here

enter image description here

I have tried with <br> and \n

Bouyalife
  • 33
  • 5

2 Answers2

1

How to add a New Line in Azure Logic app, concat method?

I have reproduced in my environment and below is expected results:

Design:

enter image description here

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:

enter image description here

enter image description here

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": {}
}
RithwikBojja
  • 5,069
  • 2
  • 3
  • 7
0

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.

c m
  • 11
  • 2