Logic APP - For Each from a Filtered Array - 通过 API 检索对象 ID
Logic APP - For Each from a Filtered Array - retrieve Object ID trough API
我正在尝试创建一个循环,但我似乎无法让它工作。
我筛选了一个共享点列表并得到以下输出结果。
接下来我想遍历 2 个广告组并取回它们的对象 ID。
出于某种原因,我似乎无法获得正确的参考。
我尝试了很多东西,这是我最后一次尝试的东西:
检索AD组名需要什么表达式?
enter image description here
{
"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": ""
}
}
]
}
您实际上不需要编写任何特定的表达式,标准的动态内容应该可以满足您的需求。
如果你使用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
结果项 2
我正在尝试创建一个循环,但我似乎无法让它工作。 我筛选了一个共享点列表并得到以下输出结果。
接下来我想遍历 2 个广告组并取回它们的对象 ID。 出于某种原因,我似乎无法获得正确的参考。
我尝试了很多东西,这是我最后一次尝试的东西:
检索AD组名需要什么表达式?
enter image description here
{
"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": ""
}
}
]
}
您实际上不需要编写任何特定的表达式,标准的动态内容应该可以满足您的需求。
如果你使用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": {}
}
这是我在数组中两项的循环中得到的结果...