LoginSignup
0
0

複数の項目の取得を使ってみる

Last updated at Posted at 2024-04-15

どうしてもId以外の項目でマスターとして使っているリストから情報を取得したい要件があります。
今回は複数の項目の取得(個人的には複数アイテムの取得と言う和訳の方がしっくりきます)。

Title eq HP0.9-3P
"body": {
        "status": 400,
        "message": "式 \"Title eq HP0.9-3P\" が無効です。 Creating query failed.\r\nclientRequestId: 604458fd-7eee-4d35-b04e-0963e54ab05c\r\nserviceRequestId: 604458fd-7eee-4d35-b04e-xxxxxxxx"
    }

もしかして、文字列を""で囲む必要がある?

Title eq " HP0.9-3P"
    "body": {
        "status": 400,
        "message": "式 \"Title eq \" HP0.9-3P\"\" が無効です。 Creating query failed.\r\nclientRequestId: 36afee83-6291-44e5-8f69-521ff61a5cec\r\nserviceRequestId: 36afee83-6291-44e5-xxxxxxxx"
    }

" でなくて ' かな?

Title eq ' HP0.9-3P'
    "body": {
        "value": []
    }

あれ!! 検索結果がない。 余分なブランクがあるな。

Title eq 'HP0.9-3P'
    "body": {
        "value": [
            {
                "@odata.etag": "\"1\"",
                "ItemInternalId": "38",
                "ID": 38,
                "Title": "HP0.9-3P",
                "field_1": "10038",
                "field_2": "105",
                "field_3": "1",
                "field_4": "0350601",
                .....

無事、取得できたけどさてどうやってIdを取る?

Jsonの解析

スキーマー

{
    "type": "object",
    "properties": {
        "Id": {
            "type": "integer"
        }
    }
}
[
  {
    "message": "Invalid type. Expected Object but got Array.",
    "lineNumber": 0,
    "linePosition": 0,
    "path": "",
    "schemaId": "#",
    "errorType": "type",
    "childErrors": []
  }
]

スキーマーが違ったかな?複数件対応してない?

サンプルに生データを突っ込んで変換。

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "@@odata.etag": {
                "type": "string"
            },
            "ItemInternalId": {
                "type": "string"
            },
            "ID": {
                "type": "integer"
            },
            "Title": {
                "type": "string"
            },
            "field_1": {
                "type": "string"
            },
            "field_2": {
                "type": "string"
            },
            "field_3": {
                "type": "string"
            },
            "field_4": {
                "type": "string"
            },
            "field_5": {
                "type": "string"
            },
            "field_6": {
                "type": "string"
            },
            "Modified": {
                "type": "string"
            },
            "Created": {
                "type": "string"
            },
            "Author": {
                "type": "object",
                "properties": {
                    "@@odata.type": {
                        "type": "string"
                    },
                    "Claims": {
                        "type": "string"
                    },
                    "DisplayName": {
                        "type": "string"
                    },
                    "Email": {
                        "type": "string"
                    },
                    "Picture": {
                        "type": "string"
                    },
                    "Department": {},
                    "JobTitle": {}
                }
            },
            "Author#Claims": {
                "type": "string"
            },
            "Editor": {
                "type": "object",
                "properties": {
                    "@@odata.type": {
                        "type": "string"
                    },
                    "Claims": {
                        "type": "string"
                    },
                    "DisplayName": {
                        "type": "string"
                    },
                    "Email": {
                        "type": "string"
                    },
                    "Picture": {
                        "type": "string"
                    },
                    "Department": {},
                    "JobTitle": {}
                }
            },
            "Editor#Claims": {
                "type": "string"
            },
            "{Identifier}": {
                "type": "string"
            },
            "{IsFolder}": {
                "type": "boolean"
            },
            "{Thumbnail}": {
                "type": "object",
                "properties": {
                    "Large": {},
                    "Medium": {},
                    "Small": {}
                }
            },
            "{Link}": {
                "type": "string"
            },
            "{Name}": {
                "type": "string"
            },
            "{FilenameWithExtension}": {
                "type": "string"
            },
            "{Path}": {
                "type": "string"
            },
            "{FullPath}": {
                "type": "string"
            },
            "{HasAttachments}": {
                "type": "boolean"
            },
            "{VersionNumber}": {
                "type": "string"
            }
        },
        "required": [
            "@@odata.etag",
            "ItemInternalId",
            "ID",
            "Title",
            "field_1",
            "field_2",
            "field_3",
            "field_4",
            "field_5",
            "field_6",
            "Modified",
            "Created",
            "Author",
            "Author#Claims",
            "Editor",
            "Editor#Claims",
            "{Identifier}",
            "{IsFolder}",
            "{Thumbnail}",
            "{Link}",
            "{Name}",
            "{FilenameWithExtension}",
            "{Path}",
            "{FullPath}",
            "{HasAttachments}",
            "{VersionNumber}"
        ]
    }
}

"type": "array",
"items": {
がポイントだろうな。

使えませんね。まただぁ

複数件ある(何にもないことこある)から?

フローの保存がコード 'InvalidVariableOperation' およびメッセージ 'The inputs of workflow run action '変数を初期化する' of type 'InitializeVariable' are not valid. The variable 'JSON の解析' must be initialized before it can be used inside action '変数を初期化する'.' で失敗しました。

今まで複数のシステムを使ってきましたが、PowerAutomate を始めMSのクラウド製品は理解できないことが多いです。こんな使いにくいシステムを本当にみなさんは問題なく使っているとしたら、すごいなぁって思いますね。

できれば、一生使いたくないシステムの筆頭です。

ほんとう、大企業なので殿様商売なのか、ユーザには向き合っているとは思えないですね。この内容には同意します。

解決策はとりあえずループの中で無駄に更新します。

image.png

テストはうまく成功したけど...

テストは何度やっても問題ないな

image.png

実際のアイテムでやってみるとエラーです。
このシステムは本当に腐っていると思います。まともに動かない。

image.png

再作成したいけど...

Apply to eachアクションってどこで選択したのか?出てこない。

image.png

探すこと15分... このUI頭おかしいとしか思えない。

image.png

どっかにも書いたけど... ないなあ

アイテムを選択した時のワークフローですが、sharepoint online からマイリストを表示してリストを出すと出てきますが、直接リストから開くと出てきません。こんなおかしなUIで誰も困らないんですかね。非常に理解に苦しみます。

image.png

何故か、一度sharepoint onlineから表示させると直接リストから開いても出てきますね。キャッシュの問題にしてはお粗末すぎる。

0
0
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
0
0