web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Adding only non-empty ...
Power Apps
Answered

Adding only non-empty data to a collection and patch it to SP

(0) ShareShare
ReportReport
Posted on by 304

Hello,

I'm currently building a canvas app for this scenario:

The app includes a form where you can choose items via comboboxes. If I submit that form through a button, I want it to additionally patch the data from the comboboxes to another sharepoint list. So my idea was to store the selected values in a collection and then patch it to the second list.

My problem now is that when a combobox has no selected items, it adds a blank row to the collection and therefore patches a blank element to the list. So I need to check, if the combobox is empty. If it is not, add the data to the collection, if it is empty, do nothing and check the next one.

I already tried the following two things:

 

 

 

If(!IsEmpty(drpComputer.SelectedItems); Collect(colDevices;
 {
 DeviceID: drpComputer.Selected.Value;
 DeviceName: comNameComputer.Selected.Value
 }
 ));;
If(!IsEmpty(drpMonitor1.SelectedItems); Collect(colDevices;
 {
 DeviceID: drpMonitor1.Selected.Value;
 DeviceName: comNameMonitor.Selected.Value
 }
 ));;
If(!IsEmpty(drpEqu1.SelectedItems); Collect(colDevices;
 {
 DeviceID: drpEqu1.Selected.Value;
 DeviceName: comNameEqu1.Selected.Value
 }
));;
If(!IsEmpty(drpEqu2.SelectedItems); Collect(colDevices;
 {
 DeviceID: drpEqu2.Selected.Value;
 DeviceName: comNameEqu2.Selected.Value
 }
));;
If(!IsEmpty(drpSmartphone.SelectedItems); Collect(colDevices;
 {
 DeviceID: drpSmartphone.Selected.Value;
 DeviceName: comNameSmartphone.Selected.Value
 }
 ));;
If(!IsEmpty(drpTablet.SelectedItems); Collect(colDevices;
 {
 DeviceID: drpTablet.Selected.Value;
 DeviceName: comNameTablet.Selected.Value
 }
 ));;
If(!IsEmpty(drpSIM.SelectedItems);Collect(colDevices;
 {
 DeviceID: drpSIM.Selected.Value;
 DeviceName: comNameSIM.Selected.Value
 }
 )
)
ClearCollect(
 colDevices;
 If(
 !IsEmpty(drpComputer.SelectedItems);
 {
 DeviceID: drpComputer.Selected.Value;
 DeviceName: comNameComputer.Selected.Value
 }
 );
 If(
 !IsEmpty(drpMonitor1.SelectedItems);
 {
 DeviceID: drpMonitor1.Selected.Value;
 DeviceName: comNameMonitor.Selected.Value
 }
 );
 If(
 !IsEmpty(drpEqu1.SelectedItems);
 {
 DeviceID: drpEqu1.Selected.Value;
 DeviceName: comNameEqu1.Selected.Value
 }
 );
 If(
 !IsEmpty(drpEqu2.SelectedItems);
 {
 DeviceID: drpEqu2.Selected.Value;
 DeviceName: comNameEqu2.Selected.Value
 }
 );
 If(
 !IsEmpty(drpSmartphone.SelectedItems);
 {
 DeviceID: drpSmartphone.Selected.Value;
 DeviceName: comNameSmartphone.Selected.Value
 }
 );
 If(
 !IsEmpty(drpTablet.SelectedItems);
 {
 DeviceID: drpTablet.Selected.Value;
 DeviceName: comNameTablet.Selected.Value
 }
 );
 If(
 !IsBlank(drpSIM.SelectedItems);
 {
 DeviceID: drpSIM.Selected.Value;
 DeviceName: comNameSIM.Selected.Value
 }
 )
)

 

 

 

 

No matter which of the code snippets I use, it seems like sometimes it does only add data if something's selected, but sometimes still adds blank rows if it isn't selected. So I'm not sure, what I do wrong here.

 

Can somebody guide me through this please?

Categories:
I have the same question (0)
  • Verified answer
    LisKr Profile Picture
    304 on at

    Found it myself😅

    I had to use !IfBlank() instead of !IsEmpty() and change "SelectedItems" to "Selected.Value". Like this:

    ClearCollect(
     colDevices;
     If(
     !IsBlank(drpComputer.Selected.Value);
     {
     DeviceID: drpComputer.Selected.Value;
     DeviceName: comNameComputer.Selected.Value
     }
     );
     If(
     !IsBlank(drpMonitor1.Selected.Value);
     {
     DeviceID: drpMonitor1.Selected.Value;
     DeviceName: comNameMonitor.Selected.Value
     }
     );
     If(
     !IsBlank(drpEqu1.Selected.Value);
     {
     DeviceID: drpEqu1.Selected.Value;
     DeviceName: comNameEqu1.Selected.Value
     }
     );
     If(
     !IsBlank(drpEqu2.Selected.Value);
     {
     DeviceID: drpEqu2.Selected.Value;
     DeviceName: comNameEqu2.Selected.Value
     }
     );
     If(
     !IsBlank(drpSmartphone.Selected.Value);
     {
     DeviceID: drpSmartphone.Selected.Value;
     DeviceName: comNameSmartphone.Selected.Value
     }
     );
     If(
     !IsBlank(drpTablet.Selected.Value);
     {
     DeviceID: drpTablet.Selected.Value;
     DeviceName: comNameTablet.Selected.Value
     }
     );
     If(
     !IsBlank(drpSIM.Selected.Value);
     {
     DeviceID: drpSIM.Selected.Value;
     DeviceName: comNameSIM.Selected.Value
     }
     )
    )

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard