LoginSignup
1
1

More than 1 year has passed since last update.

#PowerAutomate 特定の開催者の会議予定を一括で非公開にする方法

Last updated at Posted at 2021-08-19

うちの会社はですね、会議予定を基本見れるように設定している(件名だけ)のですが、とある方からの予定表については、件名にネタバレ的な要素が含まれたりするため、そもそも見れないようにしないといけないという問題が出てきました。

完全に非公開とする場合は、予定表から非公開ってすればいいだけなんですけど
image.png

過去も含めると200件以上あるので、これを一個一個非公開にするのはちょっとめんどくさいんすよね。
Outlookでも一括で非公開にするという設定もないし・・・

image.png

なので、Power Automate でできないかやってみました。

フローの全体像

内容自体はとてもシンプルです。

image.png

イベント取得で予定表から特定の予定に絞って取得し、Apply to Each で1件1件機密度をPrivateにするだけです。

フィルタクエリの書き方

実はここが一番難点でした。
まず、Power Automate のアクションにて、イベントを1件取得するとこのようなデータとなります。

{
    "headers": {
        "Pragma": "no-cache",
        "Retry-After": "15",
        "Vary": "Accept-Encoding",
        "x-ms-request-id": "ab4f9112-3c07-4064-a896-bd991189ffe6",
        "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
        "X-Content-Type-Options": "nosniff",
        "X-Frame-Options": "DENY",
        "Cache-Control": "no-store, no-cache",
        "Location": "https://japan-001.azure-apim.net/",
        "Set-Cookie": "ARRAffinity=c0c0ecb6deba;Path=/;HttpOnly;Secure;Domain=office365-je.azconn-je.p.azurewebsites.net,ARRAffinitySameSite=c0c0e2cb5cb6deba;Path=/;HttpOnly;SameSite=None;Secure;Domain=office365-je.azconn-je.p.azurewebsites.net",
        "Timing-Allow-Origin": "*",
        "x-ms-apihub-cached-response": "true",
        "Date": "Thu, 19 Aug 2021 04:18:37 GMT",
        "Content-Type": "application/json; charset=utf-8",
        "Expires": "-1",
        "Content-Length": "2536"
    },
    "body": {
        "subject": "テスト会議",
        "start": "2021-08-19T05:30:00.0000000",
        "end": "2021-08-19T06:00:00.0000000",
        "startWithTimeZone": "2021-08-19T05:30:00+00:00",
        "endWithTimeZone": "2021-08-19T06:00:00+00:00",
        "body": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=iso-2022-jp\">\r\n<meta name=\"ProgId\" content=\"Word.Document\">\r\n<meta name=\"Generator\" content=\"Microsoft Word 15\">\r\n<meta name=\"Originator\" content=\"Microsoft Word 15\">\r\n<style>\r\n<!--\r\n@font-face\r\n\t{font-family:\"Cambria Math\"}\r\n@font-face\r\n\t{font-family:\"Yu Gothic\"}\r\n@font-face\r\n\t{font-family:Calibri}\r\n@font-face\r\n\t{}\r\np.MsoNormal, li.MsoNormal, div.MsoNormal\r\n\t{margin:0cm;\r\n\tfont-size:11.0pt;\r\n\tfont-family:\"Calibri\",sans-serif}\r\na:link, span.MsoHyperlink\r\n\t{color:#0563C1;\r\n\ttext-decoration:underline}\r\na:visited, span.MsoHyperlinkFollowed\r\n\t{color:#954F72;\r\n\ttext-decoration:underline}\r\n.MsoChpDefault\r\n\t{font-family:\"Calibri\",sans-serif}\r\n@page WordSection1\r\n\t{margin:72.0pt 72.0pt 72.0pt 72.0pt}\r\ndiv.WordSection1\r\n\t{}\r\n-->\r\n</style>\r\n</head>\r\n<body lang=\"EN-US\" link=\"#0563C1\" vlink=\"#954F72\" style=\"word-wrap:break-word\">\r\n<div class=\"WordSection1\">\r\n<p class=\"MsoNormal\">&nbsp;</p>\r\n</div>\r\n</body>\r\n</html>\r\n",
        "isHtml": true,
        "responseType": "none",
        "responseTime": "0001-01-01T00:00:00+00:00",
        "id": "AAMkAGMwb_tfIAAA=",
        "createdDateTime": "2021-08-19T04:18:34.3538553+00:00",
        "lastModifiedDateTime": "2021-08-19T04:17:22.897+00:00",
        "organizer": "xxxxx@xxxxxx",
        "timeZone": "UTC",
        "iCalUId": "04000000820070D09B54C9D06DEE630C61058",
        "categories": [],
        "webLink": "https://outlook.office365.com/owa/?itemid=AAMkQ5L3D&exvsurl=1&path=/calendar/item",
        "requiredAttendees": "xxxxx@xxxxxx;",
        "optionalAttendees": "",
        "resourceAttendees": "",
        "location": "",
        "importance": "normal",
        "isAllDay": false,
        "recurrence": "none",
        "reminderMinutesBeforeStart": 15,
        "isReminderOn": true,
        "showAs": "busy",
        "responseRequested": true,
        "sensitivity": "normal"
    }
}

なので、organizer って指定すれば行けるんかなーと思ったんですよね。
そしたらこれですよ・・・

image.png

なので、実態のデータはどうなってるんだろうと思い、Graph Explorer で見てみたんですよ。

すると、organizer はこのような構成になっていました。

image.png

実態は、organizer の下に emailAddress があり、更に name と address があるんですね。

というわけで、filter クエリはこうなるんじゃないかなと思います。

organizer/emailAddress/address eq '開催者のメールアドレス'

やってみたんだけど・・・

というわけで、実際にやってみたんですが・・・

image.png

address を指定すると、時間がかかったうえに、BadGatewayでエラーが返ってきますね。

なので、メールアドレスとしては使えないので、もう一つのnameを使うしかないですね。

name でフィルターしてみる

フィルタクエリはこのようになります

organizer/emailAddress/name eq '開催者の表示名'

っでやってみるとうまく動いてくれました。

image.png

まとめ

フィルタクエリについては
Power Automate だけでは見えない項目があるので、Graph Explorerなどを使って、実際のAPIのデータを見てみる必要があるのと、いざ取得しようとしても使えないクエリもものによってはあるので、トライアンドエラーは大事だなと改めて思った次第です。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1