在PowerApps中,我如何从SharePoint列表中获取多选的选定值的集合而不使用ComboBox

发布于 2025-01-31 08:53:51 字数 304 浏览 4 评论 0 原文

我有一个具有多选择列的SharePoint列表。 在PowerApps中,我想收集选定的值。

例如,我有一个名为“类别”的多选择列,该列有一个,二,三和四的选择。 我选择了两个和四个。

我的PowerApps集成形式OneDit中的代码是,

Clear(myCollection); 
ForAll(Choices([@SMEList].Category), Collect(myCollection,ThisRecord.Value));

但这给了我一个,二,三和四。 我只想要选定的值(两个和四个)

I have a sharepoint list that has a multiselect column.
in powerapps I would like to make a collection of the selected values.

for example I have a multiselect column named category that have choices One, Two, Three, and Four.
I have selected Two and Four.

my code in powerapps Integrated Form OnEdit is

Clear(myCollection); 
ForAll(Choices([@SMEList].Category), Collect(myCollection,ThisRecord.Value));

but that is giving me One, Two, Three and Four.
I only want the selected Values (Two and Four)

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

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

发布评论

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

评论(2

独留℉清风醉 2025-02-07 08:53:51

这项工作:

ClearCollect(colMyCollection,
    Filter(
        Choices('2022-05-23_StackOverflow'.SMEList),
        Or(
            ThisRecord.Value = "Choice 2",
            ThisRecord.Value = "Choice 4"
        )
    )
)

插图:

https://i.sstatic.net/h7fdr.gif“ alt =“在此处输入图像说明”>


编辑1

  • 好。我将SP列更改为MultiSelect。
  • 应用程序的 clearCollect(collist,< sp_list_name>)
  • 插入图库控件,将其 item 属性设置为 collist 。将其 OnSelect 属性设置为 set(varrecord,thisEtem)
  • 插入表单控件,将其 item 属性设置为 lookup(collist,ID,ID) = varrecord.id)

插图

”在此处输入图像说明”


编辑2

re: ...从SharePoint列表中获取它。

  • 离开 instart 函数 clearcollect(collist,sharepointlist)
  • gallery:
    • 离开画廊项目属性 collist
    • 更改 textbox(在画廊中) text 属性属性 concat(thisitem.smelist,value,',',”)
  • 表格:
    • 您已经在Combobox中的SharePoint列表中具有值。我不清楚为什么您要操纵Combobox的外部。
    • 如何仅更改 displaymode combobox的属性为 view
    • 然后它的仅读

“在此处输入图像描述”

This works:

ClearCollect(colMyCollection,
    Filter(
        Choices('2022-05-23_StackOverflow'.SMEList),
        Or(
            ThisRecord.Value = "Choice 2",
            ThisRecord.Value = "Choice 4"
        )
    )
)

Illustrated:

enter image description here


EDIT 1

  • Ok. I changed the SP column to multiselect.
  • OnStart of the app, ClearCollect(colList, <SP_list_name>)
  • Insert a Gallery control, set its Items property to colList. Set its OnSelect property to Set(varRecord, ThisItem)
  • Insert a Form control, set its Item property to LookUp(colList, ID = varRecord.ID)

Illustrated

enter image description here


EDIT 2

RE: ...just get it from the sharepoint list .

  • Leave the OnStart function to ClearCollect(colList, SharepointList)
  • Gallery:
    • Leave the GalleryItems property to colList
    • Change the TextBox (in the Gallery) Text property to Concat(ThisItem.SMEList, Value, ",")
  • Form:
    • You already have the values from the Sharepoint list in the ComboBox. Its unclear to me why you to manipulate these values outside of the ComboBox.
    • How about just changing the DisplayMode property of the ComboBox to View.
    • Then its read-only

enter image description here

忆离笙 2025-02-07 08:53:51

我将假设 [@smelist] .category 表示您在“ smelist”上有“类别”的查找列。

您说您想要一个不使用组合盒的收藏品吗?但是,您只需要选定的值,那么如果不是从盒子中选择这些值,这些值在哪里?即使您不希望用户弄乱框,也可以将其设置为禁用,查看或可见= false。因此,我将包括那条路线,然后再谈论直接从列表中获取值。

组合框

Concat(ComboBox1.SelectedItems,Value,",")

或可能是:

Concat(ComboBox1.SelectedItems,Category,",")

这将使您将所有选定的值拉在一起。因此,它将进行:

Collect(myCollection,Concat(ComboBox1.SelectedItems,Value,","));
Collect(myCollection,Concat(ComboBox1.SelectedItems,Category,","));

或者,使用组合框的 onChange

ClearCollect( myCollection, ComboBox1.SelectedItems );

每当更改任何选定的项目时,会自动更新集合。

可能已经拥有。)

(并且在应用程序的onstart中,做 set( mycollection

,[])您 开始,在应用程序的Onstart中,例如:

Set(colList, []);
ClearCollect(colList, [@SMEList])

...基于ID,您致电该集合以获取其值,例如Seadude使用画廊演示,然后他使用结果设置了一个组合盒,基本上是关键是:查找(Collist,id = varrecord.id)

其中 varrecord 将其设置为 thisEtem 从列表中:

Gallery的OnSelect属性: set set (varrecord,thisitem)

...因此,它设置了画廊正在调用的项目。 项目使用该 lookup 公式,上面是。

(然后,他将该项目设置为相当于组合框的 发送ID并将其所有列的整个项目返回。您可以使用查找命令可以做很多事情,如果您直接违反列表,而没有ID,也可以:

clearCollect(myCollection,lookup,lookup([@smelist), “创建”&lt; today())。'类别')

...可能会在该 smelist 上可能抓住您的每个类别> 。您可以使用所需的任何条件(ID等于某物,标题等于某物等)。

任何方向

获得收藏后,您可以在 countrows 上进行 mycollection 以查看必须查看多少值,以查看它是否匹配什么您期望:

Notify(CountRows(myCollection), NotificationType.Information)

I'm going to assume that [@SMEList].Category indicates you have a Lookup column of "Category" on "SMEList".

You say you want a collection without using a combo box? Yet, you only want the selected values, so where are these getting selected, if not from a box? Even if you don't want the user to mess with the box, you can set it to disabled, view or visible = false. So I'm going to include that route and then also talk about getting the values from the list, directly.

Combo Box

Concat(ComboBox1.SelectedItems,Value,",")

or it might be:

Concat(ComboBox1.SelectedItems,Category,",")

This would let you pull all selected values together. So it would go:

Collect(myCollection,Concat(ComboBox1.SelectedItems,Value,","));
Collect(myCollection,Concat(ComboBox1.SelectedItems,Category,","));

Or, using the OnChange of the combo box:

ClearCollect( myCollection, ComboBox1.SelectedItems );

Automatically updating the collection whenever any selected items are changed.

(And in the App's OnStart, do Set(myCollection, []) as you probably already have.)

Without a combo box

You could also set the list into a collection from the beginning, in the App's OnStart, like:

Set(colList, []);
ClearCollect(colList, [@SMEList])

...and based on an ID, you call to that collection to get its values, like SeaDude demonstrated using a gallery and then he set a combo box using the result, basically the key was: LookUp(colList, ID = varRecord.ID)

Where varRecord was set to ThisItem from the list:

Gallery's OnSelect property: Set(varRecord, ThisItem)

...So it sets the item that the gallery was invoking. (And then he set that item equal to the combo box's Items property using that LookUp formula, above.)

But that code takes the collection with the list in it and lets you send in an ID and get the whole item, with all of its columns, back out. You can do a lot with a LookUp command just on its own if you are going against a list directly, and without an ID, too:

ClearCollect(myCollection,LookUp([@SMEList],'Created'<Today()).'Category')

...could potentially grab you every Category value on that SMEList that was Created before today. You can use any condition you want (ID equals something, Title equals something, etc.).

Either direction

After you get your collection, you can do a CountRows on your myCollection to see how many values it has to see if it matches what you expect:

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