Ferryzijl
Ferryzijl

Reputation: 652

Use transformed variable into steps like Send Mail (V2)

I'm creating a logic app. This app consumes a message of the service bus, transforms the XML body to json using a liquid map, and emails the json.

Although "new" transformed variable is not showing up as dynamic content.

enter image description here

Am I missing a step? I also tried using a "initialize variable" step but same results.

Upvotes: 1

Views: 57

Answers (2)

Hury Shen
Hury Shen

Reputation: 15724

The solution provided by theabodeofcode is ok, but I would like to add one point:

The output from "Transform_XML_to_JSON" can be available in "Dynamic content".

enter image description here

The reason why it doesn't show in your "Send an email" is the body of "Send an email" is string, but the output of "Transform_XML_to_JSON" is an object. If I initialize a variable and set the type as "Object", it will show in the "Dynamic content" as the screenshot above.

So for this problem, you can also use it in your "Send an email" body, just convert it to string by the expression below:

string(body('Transform_XML_to_JSON'))

enter image description here

Upvotes: 1

Mandar Dharmadhikari
Mandar Dharmadhikari

Reputation: 1119

I tried the same in my logic app, looks like the dynamic output of the liquid templates are not available in the dynamic content. You can however access the output of the transform shapes using expressions. use following expression in the expression window

outputs('Transform_XML_to_JSON')?['body']

Or in the code editor the api connection would something like following

 "Send_an_email_(V2)": {
                "inputs": {
                    "body": {
                        "Body": "<p>@{outputs('Transform_XML_JSON')?['body']}</p>",
                        "Subject": "Mail Triggered using Logic Apps",
                        "To": "[email protected]"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['office365']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/v2/Mail"
                },
                "runAfter": {
                    "Transform_XML_to_JSON": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }

Upvotes: 1

Related Questions