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

Announcements

News and Announcements icon
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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 463

#2
WarrenBelz Profile Picture

WarrenBelz 364 Most Valuable Professional

#3
11manish Profile Picture

11manish 275

Last 30 days Overall leaderboard