逻辑应用提取字符串并将它们分组到电子邮件正文中

huangapple go评论86阅读模式
英文:

Logic App Extracting String and Group them to Body Email

问题

这里是代码段的翻译,提取了您期望的AppId的部分:

  • Youtube
  • ios
  • strongbox
  • ......

您尝试了以下操作:

逻辑应用提取字符串并将它们分组到电子邮件正文中

并且获得了以下结果:

逻辑应用提取字符串并将它们分组到电子邮件正文中

问题是:如果我要发送邮件,它将至少发送23次,这将引起混乱。如何像这样对它们进行分组:

  • Youtube
  • ios
  • strongbox

并且只发送一次。感谢您的提前贡献。

英文:

Hello here is the snippet of my code and I am trying to get the AppId from this represented in the following manner in oder to send it via mail.

 {
                        "appId": "com.google.ios.youtube"
                    },
                    {
                        "appId": "com.keepassium.ios"
                    },
                    {
                        "appId": "com.markmcguill.strongbox"
                    },
                    {
                        "appId": "com.microsoft.azureauthenticator"
                    },
                    {
                        "appId": "com.microsoft.Office.Excel"
                    },
                    {
                        "appId": "com.microsoft.Office.Powerpoint"
                    },
                    {
                        "appId": "com.microsoft.Office.Word"
                    },
                    {
                        "appId": "com.microsoft.onenote"
                    },
                    {
                        "appId": "com.microsoft.rdc.ios"
                    },
                    {
                        "appId": "com.microsoft.skydrive"
                    }

What i expect is:
Youtube
ios
strongbox
......

I tried this

逻辑应用提取字符串并将它们分组到电子邮件正文中

and I got this one

逻辑应用提取字符串并将它们分组到电子邮件正文中

The Problem is: if I want to send a mail this will be sent at least 23 times and it'll cause chaos. How can I group them like this:

  • Youtube
  • ios
  • strongbox

and send them once. Sorry to be long and thanks in advance for your contribution.

答案1

得分: 0

我在我的环境中复现并获得了以下预期结果:

您可以使用**空数组变量使用空格连接操作符**来实现此操作:

逻辑应用提取字符串并将它们分组到电子邮件正文中

输出:

逻辑应用提取字符串并将它们分组到电子邮件正文中

之后,您可以将电子邮件作为操作。

代码视图:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "For_each": {
                "actions": {
                    "Append_to_array_variable": {
                        "inputs": {
                            "name": "var",
                            "value": "@outputs('Compose')"
                        },
                        "runAfter": {
                            "Compose": [
                                "Succeeded"
                            ]
                        },
                        "type": "AppendToArrayVariable"
                    },
                    "Compose": {
                        "inputs": "@last(split(items('For_each')['appId'],'.'))",
                        "runAfter": {},
                        "type": "Compose"
                    }
                },
                "foreach": "@body('Parse_JSON')",
                "runAfter": {
                    "Parse_JSON": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Initialize_variable": {
                "inputs": {
                    "variables": [
                        {
                            "name": "var",
                            "type": "array"
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            },
            "Join": {
                "inputs": {
                    "from": "@variables('var')",
                    "joinWith": " "
                },
                "runAfter": {
                    "For_each": [
                        "Succeeded"
                    ]
                },
                "type": "Join"
            },
            "Parse_JSON": {
                "inputs": {
                    "content": "@triggerBody()",
                    "schema": {
                        "items": {
                            "properties": {
                                "appId": {
                                    "type": "string"
                                }
                            },
                            "required": [
                                "appId"
                            ],
                            "type": "object"
                        },
                        "type": "array"
                    }
                },
                "runAfter": {
                    "Initialize_variable": [
                        "Succeeded"
                    ]
                },
                "type": "ParseJson"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {}
}

编辑:

在此处使用了**空格 - 空格**:

逻辑应用提取字符串并将它们分组到电子邮件正文中

输出:

逻辑应用提取字符串并将它们分组到电子邮件正文中

英文:

I have reproduced in my environment and got expected results as below:

You can use Empty array variable and Join Operator with space for this:

逻辑应用提取字符串并将它们分组到电子邮件正文中

Output:

逻辑应用提取字符串并将它们分组到电子邮件正文中

After this you can use Email as an action.

Code view:

{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"Append_to_array_variable": {
"inputs": {
"name": "var",
"value": "@outputs('Compose')"
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "AppendToArrayVariable"
},
"Compose": {
"inputs": "@last(split(items('For_each')['appId'],'.'))",
"runAfter": {},
"type": "Compose"
}
},
"foreach": "@body('Parse_JSON')",
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "Foreach"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "var",
"type": "array"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Join": {
"inputs": {
"from": "@variables('var')",
"joinWith": " "
},
"runAfter": {
"For_each": [
"Succeeded"
]
},
"type": "Join"
},
"Parse_JSON": {
"inputs": {
"content": "@triggerBody()",
"schema": {
"items": {
"properties": {
"appId": {
"type": "string"
}
},
"required": [
"appId"
],
"type": "object"
},
"type": "array"
}
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "ParseJson"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}

EDIT:

Used space - space here:

逻辑应用提取字符串并将它们分组到电子邮件正文中

Output:

逻辑应用提取字符串并将它们分组到电子邮件正文中

huangapple
  • 本文由 发表于 2023年7月13日 16:53:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76677562.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定