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

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

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.

  1. {
  2. "appId": "com.google.ios.youtube"
  3. },
  4. {
  5. "appId": "com.keepassium.ios"
  6. },
  7. {
  8. "appId": "com.markmcguill.strongbox"
  9. },
  10. {
  11. "appId": "com.microsoft.azureauthenticator"
  12. },
  13. {
  14. "appId": "com.microsoft.Office.Excel"
  15. },
  16. {
  17. "appId": "com.microsoft.Office.Powerpoint"
  18. },
  19. {
  20. "appId": "com.microsoft.Office.Word"
  21. },
  22. {
  23. "appId": "com.microsoft.onenote"
  24. },
  25. {
  26. "appId": "com.microsoft.rdc.ios"
  27. },
  28. {
  29. "appId": "com.microsoft.skydrive"
  30. }

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

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

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

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

输出:

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

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

代码视图:

  1. {
  2. "definition": {
  3. "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
  4. "actions": {
  5. "For_each": {
  6. "actions": {
  7. "Append_to_array_variable": {
  8. "inputs": {
  9. "name": "var",
  10. "value": "@outputs('Compose')"
  11. },
  12. "runAfter": {
  13. "Compose": [
  14. "Succeeded"
  15. ]
  16. },
  17. "type": "AppendToArrayVariable"
  18. },
  19. "Compose": {
  20. "inputs": "@last(split(items('For_each')['appId'],'.'))",
  21. "runAfter": {},
  22. "type": "Compose"
  23. }
  24. },
  25. "foreach": "@body('Parse_JSON')",
  26. "runAfter": {
  27. "Parse_JSON": [
  28. "Succeeded"
  29. ]
  30. },
  31. "type": "Foreach"
  32. },
  33. "Initialize_variable": {
  34. "inputs": {
  35. "variables": [
  36. {
  37. "name": "var",
  38. "type": "array"
  39. }
  40. ]
  41. },
  42. "runAfter": {},
  43. "type": "InitializeVariable"
  44. },
  45. "Join": {
  46. "inputs": {
  47. "from": "@variables('var')",
  48. "joinWith": " "
  49. },
  50. "runAfter": {
  51. "For_each": [
  52. "Succeeded"
  53. ]
  54. },
  55. "type": "Join"
  56. },
  57. "Parse_JSON": {
  58. "inputs": {
  59. "content": "@triggerBody()",
  60. "schema": {
  61. "items": {
  62. "properties": {
  63. "appId": {
  64. "type": "string"
  65. }
  66. },
  67. "required": [
  68. "appId"
  69. ],
  70. "type": "object"
  71. },
  72. "type": "array"
  73. }
  74. },
  75. "runAfter": {
  76. "Initialize_variable": [
  77. "Succeeded"
  78. ]
  79. },
  80. "type": "ParseJson"
  81. }
  82. },
  83. "contentVersion": "1.0.0.0",
  84. "outputs": {},
  85. "parameters": {},
  86. "triggers": {
  87. "manual": {
  88. "inputs": {
  89. "schema": {}
  90. },
  91. "kind": "Http",
  92. "type": "Request"
  93. }
  94. }
  95. },
  96. "parameters": {}
  97. }

编辑:

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

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

输出:

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

英文:

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:

  1. {
  2. "definition": {
  3. "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
  4. "actions": {
  5. "For_each": {
  6. "actions": {
  7. "Append_to_array_variable": {
  8. "inputs": {
  9. "name": "var",
  10. "value": "@outputs('Compose')"
  11. },
  12. "runAfter": {
  13. "Compose": [
  14. "Succeeded"
  15. ]
  16. },
  17. "type": "AppendToArrayVariable"
  18. },
  19. "Compose": {
  20. "inputs": "@last(split(items('For_each')['appId'],'.'))",
  21. "runAfter": {},
  22. "type": "Compose"
  23. }
  24. },
  25. "foreach": "@body('Parse_JSON')",
  26. "runAfter": {
  27. "Parse_JSON": [
  28. "Succeeded"
  29. ]
  30. },
  31. "type": "Foreach"
  32. },
  33. "Initialize_variable": {
  34. "inputs": {
  35. "variables": [
  36. {
  37. "name": "var",
  38. "type": "array"
  39. }
  40. ]
  41. },
  42. "runAfter": {},
  43. "type": "InitializeVariable"
  44. },
  45. "Join": {
  46. "inputs": {
  47. "from": "@variables('var')",
  48. "joinWith": " "
  49. },
  50. "runAfter": {
  51. "For_each": [
  52. "Succeeded"
  53. ]
  54. },
  55. "type": "Join"
  56. },
  57. "Parse_JSON": {
  58. "inputs": {
  59. "content": "@triggerBody()",
  60. "schema": {
  61. "items": {
  62. "properties": {
  63. "appId": {
  64. "type": "string"
  65. }
  66. },
  67. "required": [
  68. "appId"
  69. ],
  70. "type": "object"
  71. },
  72. "type": "array"
  73. }
  74. },
  75. "runAfter": {
  76. "Initialize_variable": [
  77. "Succeeded"
  78. ]
  79. },
  80. "type": "ParseJson"
  81. }
  82. },
  83. "contentVersion": "1.0.0.0",
  84. "outputs": {},
  85. "parameters": {},
  86. "triggers": {
  87. "manual": {
  88. "inputs": {
  89. "schema": {}
  90. },
  91. "kind": "Http",
  92. "type": "Request"
  93. }
  94. }
  95. },
  96. "parameters": {}
  97. }

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:

确定