SharePoint是/否字段不能从Power Automate更新

时间:2019-12-07 22:24:47

标签: sharepoint sharepoint-online power-automate

我有一个简单的流程,可以在收到新电子邮件时创建一个项目:

When a new email arrives > Parse JSON > Create item

该流确实起作用,但是当输入值为true时,“是/否”字段都不会更新为“是”;默认值为否,因此,假值可以按预期工作。

收到新电子邮件

{ ... "Driver": true, ... }

解析JSON

{
    ...
    "Driver": true,
    ...
}

创建项目

输入

...
Driver
 true
...

输出

...
Driver
 true
...

SharePoint中的列表项

Driver (Yes/No) is un-checked/false

我已阅读“是/否”列(“大流量”)上“流程失败”的解决方案,但无济于事。

https://powerusers.microsoft.com/t5/Using-Flows/Flow-fails-on-Yes-No-column-Big-Flow/m-p/35116#M1086

为确认,我未成功尝试添加以下动态内容选项:

// In-correctly assumed the below line should work since a Yes/No field is a simple Boolean field;
// returns true but doesn't check the Driver checkbox in Item
body('Parse_JSON')?['json']?['Driver']

// Solution to Flow fails on Yes/No column (Big Flow);
// https://powerusers.microsoft.com/t5/Using-Flows/Flow-fails-on-Yes-No-column-Big-Flow/m-p/35116#M1086
// returns true but doesn't check the Driver checkbox in Item
equals(body('Parse_JSON')?['json']?['Driver'], true)

// All returns true but doesn't check the Driver checkbox in Item
if(body('Parse_JSON')?['json']?['Driver'], true, false)
if(body('Parse_JSON')?['json']?['Driver'], 'True', 'False')
if(equals(body('Parse_JSON')?['json']?['Driver'], true), true, false)
if(equals(body('Parse_JSON')?['json']?['Driver'], true), 'True', 'False')

// Throws error; and Flow fails as expected
if(body('Parse_JSON')?['json']?['Driver'], 'Yes', 'No')
if(equals(body('Parse_JSON')?['json']?['Driver'], true), 'Yes', 'No')

现在,我只是在猜测,所以我想念什么?!

总而言之,我的问题是从MS Flow创建项目时如何成功更新是/否字段?

1 个答案:

答案 0 :(得分:0)

我偶然发现了一种变通方法和可接受的解决方案,其中使用“向SharePoint发送HTTP请求”操作来更新“超链接”字段的“描述(显示文本)和URL”字段。

我发现这篇文章最有帮助:Updating a Hyperlink field (both url and description) using Flow?

当输入值为true时,我使用相同的方法将所有“是/否”字段更新为“是”。以下是其他人可能会有用的关键设置。

Site Address: https://MyFakeSite.sharepoint.com/
Method: POST
Url: _api/web/lists/GetByTitle('MyFakeList')/Items(@{body('Create_item')?['ID']})
Headers: {
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose",
  "X-HTTP-Method": "MERGE",
  "IF-MATCH": "*"
}
Body: {
    '__metadata': {
      'type': 'SP.Data.MyFakeListItem'
    },
    'Driver': @{toLower(string(equals(body('Parse_JSON')?['json']?['Driver'], true)))},
    ...
}