cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
santukondapally
Helper II
Helper II

Collection is returning empty when there is no attachment

I am using an attachment control in powerapps and storing the metadata to a list. The data is getting stored only when there is an attachment.When i checked compose action if there is no attachment the collection is coming as empty . how to check before flow.

Submit Button Logic:

Set(varSuccess,Blank());
Clear(colAttachGallery);
ForAll(Galattach.AllItems,Collect(colAttachGallery,{Name:lbl_AttachDocument.Text,DataStream:ImgDataStream.Image,FirstName:Txt_FirstName.Text,LastName:Txt_Lastname.Text,Email:Txt_Email.Text,SupervisorEmail:Txt_SupervisorEmail.Text,BlogTitle:Txt_BlogTitle.Text,User:Cmbx_Email.Selected.Mail,Lead:Cmbx_Lead.Selected.Mail}));
Set(varSuccess,SendFilesWithMetadataToSharePoint.Run(JSON(colAttachGallery,JSONFormat.IncludeBinaryData)).success);If(varSuccess="Yes",Clear(colAttachments);Notify("Your files have been successfully upload to the Blog Submissions",NotificationType.Success,3000);
Refresh('Blog Submissions');
Reset(Txt_FirstName);
Reset(Txt_Lastname);Reset(Txt_SupervisorEmail);Reset(Txt_BlogTitle);Reset(ctrl_Attachment);Set(CmbxEmailReset, true );Set(CmbxLeadReset, true );Navigate(Sucess,ScreenTransition.CoverRight),Notify("Error uploading files. Please try again or contact administrator",NotificationType.Error,3000))

 

 

3 REPLIES 3
gabibalaban
Super User
Super User

Hi @santukondapally ,

 

I think that the most elegant way is to set your Submit Button - DisplayMode property to:

If(

   IsEmpty(Galattach.AllItems),

   DisplayMode.Disabled,

   DisplayMode.Edit)

In this way, the user can't submit empty collections to flow (because the button is disabled).

 

Hope it helps !

@gabibalaban  I wan't  to pass the data even if the attachment is empty? In my case Attachment is not mandatory.

@santukondapally ,

Well in this case, if the flow is triggered, we have to see the flow.

From my point of view, after you parse the JSON  you have to create a Sharepoint - create item action and then to use a condition to see if the DataStream is empty or not and for "not empty" branch to add a Sharepoint - Add an attach action using the ID of the Sharepoint - create item action.

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,649)