0

我正在尝试创建一个循环,但我似乎无法让它工作。我过滤了一个共享点列表,结果得到了以下输出。

接下来,我想遍历 2 个广告组并取回它们的对象 ID。出于某种原因,我似乎无法获得正确的参考。

我尝试了很多东西,这是我尝试的最后一个:

我需要什么表达式来检索 AD 组名称?

在此处输入图像描述

{
    "body": [
        {
            "@odata.etag": "\"4\"",
            "ItemInternalId": "1",
            "ID": 1,
            "Title": "Access Rights",
            "ReportName": {
                "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                "Id": 4,
                "Value": "WOL Campaign Report"
            },
            "Environment#Id": 1,
            "Azure_x0020_AD_x0020_Group": "PT_PBI_TST_AR_WOLCAMPAIGN_APPViewer",
            "Modified": "2022-01-14T16:30:47Z",
            "Created": "2022-01-13T23:56:02Z",
            "Author": {
                "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                "Claims": "",
                "DisplayName": "",
                "Email": "",
                "Picture": ""
            },
            "Author#Claims": "",
            "Editor": {
                "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                "Claims": "",
                "DisplayName": "",
                "Email": "",
                "Picture": ""
            }
        },
        {
            "@odata.etag": "\"1\"",
            "ItemInternalId": "4",
            "ID": 4,
            "Title": "66",
            "ReportName": {
                "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                "Id": 4,
                "Value": "WOL Campaign Report"
            },
            "Environment#Id": 1,
            "Azure_x0020_AD_x0020_Group": "PT_PBI_TST_RLS_WOLCAMPAIGN_AdminViewer",
            "Modified": "2022-01-14T16:32:00Z",
            "Created": "2022-01-14T16:32:00Z",
            "Author": {
                "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                "Claims": "",
                "DisplayName": "",
                "Email": "",
                "Picture": ""
            },
            "Author#Claims": "",
            "Editor": {
                "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                "Claims": "",
                "DisplayName": "",
                "Email": "",
                "Picture": ""
            }
        }
    ]
}
4

1 回答 1

0

您实际上不需要编写任何特定的表达式,标准的动态内容应该可以满足您的需求。

如果您使用该Parse JSON动作,它将使生活变得更加轻松。我不知道你是不是,但它看起来与我的例子没什么不同。

流动

但是,在模板中(基于我整理的内容),这是动态内容所见即所得编辑器生成的表达式......

@items('For_Each_Item_on_Body')?['Azure_x0020_AD_x0020_Group']

您可以将此 JSON 模板(代码视图)导入您的租户进行测试。

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "For_Each_Item_on_Body": {
                "actions": {
                    "Set_variable": {
                        "inputs": {
                            "name": "Azure AD Group",
                            "value": "@items('For_Each_Item_on_Body')?['Azure_x0020_AD_x0020_Group']"
                        },
                        "runAfter": {},
                        "type": "SetVariable"
                    }
                },
                "foreach": "@body('Parse_JSON')?['body']",
                "runAfter": {
                    "Initialize_Azure_AD_Group_Variable": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Initialize_Azure_AD_Group_Variable": {
                "inputs": {
                    "variables": [
                        {
                            "name": "Azure AD Group",
                            "type": "string"
                        }
                    ]
                },
                "runAfter": {
                    "Parse_JSON": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            },
            "Parse_JSON": {
                "inputs": {
                    "content": {
                        "body": [
                            {
                                "Author": {
                                    "Claims": "",
                                    "DisplayName": "",
                                    "Email": "",
                                    "Picture": "",
                                    "odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser"
                                },
                                "Author#Claims": "",
                                "Azure_x0020_AD_x0020_Group": "PT_PBI_TST_AR_WOLCAMPAIGN_APPViewer",
                                "Created": "2022-01-13T23:56:02Z",
                                "Editor": {
                                    "Claims": "",
                                    "DisplayName": "",
                                    "Email": "",
                                    "Picture": "",
                                    "odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser"
                                },
                                "Environment#Id": 1,
                                "ID": 1,
                                "ItemInternalId": "1",
                                "Modified": "2022-01-14T16:30:47Z",
                                "ReportName": {
                                    "Id": 4,
                                    "Value": "WOL Campaign Report",
                                    "odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
                                },
                                "Title": "Access Rights",
                                "odata.etag": "\"4\""
                            },
                            {
                                "Author": {
                                    "Claims": "",
                                    "DisplayName": "",
                                    "Email": "",
                                    "Picture": "",
                                    "odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser"
                                },
                                "Author#Claims": "",
                                "Azure_x0020_AD_x0020_Group": "PT_PBI_TST_RLS_WOLCAMPAIGN_AdminViewer",
                                "Created": "2022-01-14T16:32:00Z",
                                "Editor": {
                                    "Claims": "",
                                    "DisplayName": "",
                                    "Email": "",
                                    "Picture": "",
                                    "odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser"
                                },
                                "Environment#Id": 1,
                                "ID": 4,
                                "ItemInternalId": "4",
                                "Modified": "2022-01-14T16:32:00Z",
                                "ReportName": {
                                    "Id": 4,
                                    "Value": "WOL Campaign Report",
                                    "odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
                                },
                                "Title": "66",
                                "odata.etag": "\"1\""
                            }
                        ]
                    },
                    "schema": {
                        "properties": {
                            "body": {
                                "items": {
                                    "properties": {
                                        "Author": {
                                            "properties": {
                                                "Claims": {
                                                    "type": "string"
                                                },
                                                "DisplayName": {
                                                    "type": "string"
                                                },
                                                "Email": {
                                                    "type": "string"
                                                },
                                                "Picture": {
                                                    "type": "string"
                                                },
                                                "odata.type": {
                                                    "type": "string"
                                                }
                                            },
                                            "type": "object"
                                        },
                                        "Author#Claims": {
                                            "type": "string"
                                        },
                                        "Azure_x0020_AD_x0020_Group": {
                                            "type": "string"
                                        },
                                        "Created": {
                                            "type": "string"
                                        },
                                        "Editor": {
                                            "properties": {
                                                "Claims": {
                                                    "type": "string"
                                                },
                                                "DisplayName": {
                                                    "type": "string"
                                                },
                                                "Email": {
                                                    "type": "string"
                                                },
                                                "Picture": {
                                                    "type": "string"
                                                },
                                                "odata.type": {
                                                    "type": "string"
                                                }
                                            },
                                            "type": "object"
                                        },
                                        "Environment#Id": {
                                            "type": "integer"
                                        },
                                        "ID": {
                                            "type": "integer"
                                        },
                                        "ItemInternalId": {
                                            "type": "string"
                                        },
                                        "Modified": {
                                            "type": "string"
                                        },
                                        "ReportName": {
                                            "properties": {
                                                "Id": {
                                                    "type": "integer"
                                                },
                                                "Value": {
                                                    "type": "string"
                                                },
                                                "odata.type": {
                                                    "type": "string"
                                                }
                                            },
                                            "type": "object"
                                        },
                                        "Title": {
                                            "type": "string"
                                        },
                                        "odata.etag": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "odata.etag",
                                        "ItemInternalId",
                                        "ID",
                                        "Title",
                                        "ReportName",
                                        "Environment#Id",
                                        "Azure_x0020_AD_x0020_Group",
                                        "Modified",
                                        "Created",
                                        "Author",
                                        "Author#Claims",
                                        "Editor"
                                    ],
                                    "type": "object"
                                },
                                "type": "array"
                            }
                        },
                        "type": "object"
                    }
                },
                "runAfter": {},
                "type": "ParseJson"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "Recurrence": {
                "evaluatedRecurrence": {
                    "frequency": "Month",
                    "interval": 3
                },
                "recurrence": {
                    "frequency": "Month",
                    "interval": 3
                },
                "type": "Recurrence"
            }
        }
    },
    "parameters": {}
}

这是我在数组中的两个项目的循环中得到的结果......

结果项目 1

项目 1

结果项目 2

第 2 项

于 2022-01-19T11:14:45.437 回答