如何查找数组中是否存在键 - Typescript - Microsoft flows

How to find if a key is present in an array - Typescript - Microsoft flows

我有多个用户,我想根据他们的办公地点过滤他们 我通过“搜索用户 (V2)”流程获取位置,其中 returns 包含 ID、电子邮件、国家/地区等的关于每个用户的一系列信息

他们中的一些人没有所有这些信息,在我的情况下他们根本没有(办公地点),这将导致流程显示错误

这是我的流程

这是结果

和错误

有什么想法吗? 谢谢!

我有点困惑为什么你在 Search for users 调用后立即使用带有 first() 函数的 Condition 操作,这与描述不符关于你的问题。

如果是我,我会使用 Filter array 操作根据需要分解该列表,然后您可以从那里使用它。

在我下面的测试中,您可以看到我正在根据返回数组中的术语 Head Office 进行过滤。

我有 3 个用户被撤回,其中两个 OfficeLocation 属性 设置为 总部

过滤前

[
  {
    "Id": "c9692d85-ae00-470f-8544-4ded06082d59",
    "AccountEnabled": true,
    "BusinessPhones": [],
    "DisplayName": "Automation",
    "Mail": "automation@somewhere.com",
    "MailNickname": "automation",
    "OfficeLocation": "Head Office",
    "UserPrincipalName": "automation@somewhere.com"
  },
  {
    "Id": "8ddf4a13-fa28-4c76-8a79-dfcc680b57b9",
    "AccountEnabled": true,
    "BusinessPhones": [
      "4251001000"
    ],
    "DisplayName": "Joe Bloggs",
    "GivenName": "Joe",
    "Mail": "joe.bloggs@somewhere.com",
    "MailNickname": "joe.bloggs",
    "Surname": "Bloggs",
    "UserPrincipalName": "joe.bloggs@somewhere.com"
  },
  {
    "Id": "9d903297-2777-48d8-beb3-95e4e9ad2851",
    "AccountEnabled": true,
    "BusinessPhones": [],
    "DisplayName": "Jane Doe",
    "GivenName": "Jane",
    "Mail": "jane.doe@somewhere.com",
    "MailNickname": "jane.doe",
    "OfficeLocation": "Head Office",
    "Surname": "Doe",
    "UserPrincipalName": "jane.doe@somewhere.com"
  }
]

过滤后

[
  {
    "Id": "c9692d85-ae00-470f-8544-4ded06082d59",
    "AccountEnabled": true,
    "BusinessPhones": [],
    "DisplayName": "Automation",
    "Mail": "automation@somewhere.com",
    "MailNickname": "automation",
    "OfficeLocation": "Head Office",
    "UserPrincipalName": "automation@somewhere.com"
  },
  {
    "Id": "9d903297-2777-48d8-beb3-95e4e9ad2851",
    "AccountEnabled": true,
    "BusinessPhones": [],
    "DisplayName": "Jane Doe",
    "GivenName": "Jane",
    "Mail": "jane.doe@somewhere.com",
    "MailNickname": "jane.dow",
    "OfficeLocation": "Head Office",
    "Surname": "Doe",
    "UserPrincipalName": "jane.doe@somewhere.com"
  }
]