使用Power应用程序在SharePoint中的多值选择列中添加新值,而无需覆盖现有值

发布于 2025-02-10 23:56:52 字数 803 浏览 0 评论 0原文

我有一个SharePoint列表,其中包含一个带有“多重选择”选项的选择列。此列表中的每个项目都包含与给定用户的偏好相关的数据,并且选择列将存储每个用户的“最受欢迎”报告的ID。

我想在Power Apps中编写一个补丁公式,该公式为此列写了一个新值,但保留了现有值。这是我当前公式的摘录,当用户选择“添加到收藏夹”按钮时触发,其中'fairter'是已经包含值的选择列:

Patch(
            'Platform User Preferences',
            LookUp(
                'Platform User Preferences',
                UserEmail = User().Email
            ),
            {Favorites: [ThisItem.ID]}
        )

当前状态,此公式覆盖选择列中的现有值,新的单个值,而不是与现有值一起添加它。

我尝试过的一种方法(基于在线阅读类似的用例)是从收藏夹列创建一个集合,将新值添加到该集合中,然后将整个集合添加回SP。但是,我也有类似的问题,因为我不完全了解基于多价选择列的集合的模型。例如,以下内容似乎还完全擦除了集合中的数据,而不是添加:

ClearCollect(favslist,Filter('Platform User Preferences',UserEmail = User().Email).Favorites);
Collect(favslist, {Value: ThisItem.ID});

解决此问题的任何帮助将不胜感激!

I have a SharePoint list that contains a choice column with the 'multiple selection' option turned on. Each item in this list contains data related to preferences for a given user, and the choice column will store the IDs for each of the user's 'favorited' reports.

I would like to write a Patch formula in Power Apps that writes a new value to this column, but retains the existing values. Here is an extract from my current formula, triggered when a user selects the 'Add To Favorites' button, where 'Favorites' is the choice column that already contains values:

Patch(
            'Platform User Preferences',
            LookUp(
                'Platform User Preferences',
                UserEmail = User().Email
            ),
            {Favorites: [ThisItem.ID]}
        )

Current state, this formula overwrites the existing values in the choice column with the new single value, instead of adding it alongside the existing values.

One approach I have attempted (based on reading similar use cases online) is to create a collection from the Favorites column, add the new value to that collection, then patch the entire collection back to SP. However, I have had similar problems doing this as I do not fully understand the model of a collection that is based on a multi-value choice column. For example, the following also appears to completely wipe the data in the collection, rather than add to it:

ClearCollect(favslist,Filter('Platform User Preferences',UserEmail = User().Email).Favorites);
Collect(favslist, {Value: ThisItem.ID});

Any help with solving this problem would be most appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

榕城若虚 2025-02-17 23:56:53

您需要创建另一个包含现有收藏夹的每个选择的集合。现在,您的“热爱”集合包含一个包含所有现有喜欢的选择的项目,然后您添加新项目。这种方式无法正确格式。
在修补之前,尝试使用forall并收集现有项目之前,请尝试更新现有代码:

ClearCollect(existingfavslist,Filter('Platform User Preferences',UserEmail = User().Email).Favorites);
ForAll(existingfavlist, Collect(favslist, ThisRecord.Value));
Collect(favslist, {Value: ThisItem.ID});

然后将您的集合“ Favslist”修补到列表中

You'll need to create another collection that contains each selection of the existing favorites. Right now your 'favlist' collection contains one item that contains all the existing favorite selections, then youre adding you new item. This isn't formatted correctly this way.
Try updating your existing code before you patch, by using a ForAll and collect the existing items:

ClearCollect(existingfavslist,Filter('Platform User Preferences',UserEmail = User().Email).Favorites);
ForAll(existingfavlist, Collect(favslist, ThisRecord.Value));
Collect(favslist, {Value: ThisItem.ID});

Then just patch your collection 'favslist' to the list

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文