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 / Check if Collection Co...
Power Apps
Unanswered

Check if Collection Column have a value

(0) ShareShare
ReportReport
Posted on by

Pls let me know what is wrong with the below code

 

I'm checking two collections and if both are empty, I want the error to prompt.

 

But now it is validating this code and submitting the form even if the collections is empty

 

If(
 CountRows(
 Filter(NewCollection,
 Or(
 IsBlank(A),
 IsBlank(B),
 IsBlank(C)
 )
 )
 ) && 
 CountRows(
 Filter(EditCollection,
 Or(
 IsBlank(D),
 IsBlank(E),
 IsBlank(F)
 )
 )
 ) > 0 ,
 Notify(
 "Admin Role is required",
 Error
 ),
 SubmitForm(Form))

 

 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @indhaa 

    You are logically And'ing (&&) two numeric values...this will not give you the results you want.

    Change your && to plus ( + )

    If(
     CountRows(
     Filter(NewCollection,
     Or(
     IsBlank(A),
     IsBlank(B),
     IsBlank(C)
     )
     )
     ) +
     CountRows(
     Filter(EditCollection,
     Or(
     IsBlank(D),
     IsBlank(E),
     IsBlank(F)
     )
     )
     ) > 0 ,
     Notify(
     "Admin Role is required",
     Error
     ),
     SubmitForm(Form))

     

    I hope this is helpful for you.

  • indhaa Profile Picture
    on at

    Randy,

     

    I want if either count is true then the condition is true. In that case how will the code be.

     

    So I'm checking if countrows of NewCollection >0 or countrows of EditCollection >0 . 

  • indhaa Profile Picture
    on at

    I tried like this first 

    If(
     (CountRows(
     Filter(NewCollection,
     Or(
     IsBlank(A),
     IsBlank(B),
     IsBlank(C)
     )
     )
     ) > 0 ) && 
    	(CountRows(
     Filter(EditCollection,
     Or(
     IsBlank(D),
     IsBlank(E),
     IsBlank(F)
     )
     )
     ) > 0 ),
     Notify(
     "Admin Role is required",
     Error
     ),
    SubmitForm(Form))
  • indhaa Profile Picture
    on at

    Hi @WarrenBelz 

     

    can help me out?

  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at

    @indhaa ,

    You we missing the >0 argument on the first part.
    BTW @RandyHayes is probably asleep right now - we can only respond as time zone allows.

    If(
     CountRows(
     Filter(
     NewCollection,
     IsBlank(A) || IsBlank(B) || IsBlank(C)
     )
     ) > 0 ||
     CountRows(
     Filter(
     EditCollection,
     IsBlank(D) || IsBlank(E) || IsBlank(F)
     )
     ) > 0,
     Notify(
     "Admin Role is required",
     Error
     ),
     SubmitForm(Form)
    )

    Please also take some time to understand the logic when you get a solution - it will help you greatly for the future.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • indhaa Profile Picture
    on at

    Yah, I assumed @RandyHayes  was asleep that's why I tag you since I get response from you at this time and was hoping you will respond even if it is Sunday. 

    I was hoping to live the app today, sorry for disturbing on a Sunday. I will check this out


  • indhaa Profile Picture
    on at

    Hi,

     

    Hope you are available

    So I added as below. Even if the Edit collections is not Empty it is not submitting the form when the NEW collection is empty. I tested by keeping only the Edit Collection and it submit in that case. 

    So I tried by changing by putting the Edit Collection first and then the New but still it doesn't work. Only if New Collection is not empty it is submitting. I don't know why since I cant see any issue with the code.

     

    Pls Let me know what I'm missing

     

     

    If(
     CountRows(
     Filter(
     NewCollection,
     IsBlank(A) || IsBlank(B) || IsBlank(C)
     ) > 0 ||
     CountRows(
     Filter(
     EditCollection,
     IsBlank(D) || IsBlank(E) || IsBlank(F)
     ) > 0,
     Notify(
     "Admin Role is required",
     Error
     ),
     SubmitForm(Form)
    )

     

  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at

    @indhaa ,

    Problem with free-typing code on a Sunday - that syntax should be invalid as it is missing two brackets - I have fixed it on the original post

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

     

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @indhaa 

    Yes...sleeping!  Start of a Sunday morning here now.

     

    Did you try the formula I provided you?  (slightly revised version below)

    If(
     (
     CountRows(Filter(NewCollection, Or(IsBlank(A), IsBlank(B), IsBlank(C)))
     +
     CountRows(Filter(EditCollection, Or(IsBlank(D), IsBlank(E), IsBlank(F)))
     ) > 0 ,
     Notify("Admin Role is required", Error),
    
     SubmitForm(Form)
    )

      

  • indhaa Profile Picture
    on at

    Hi

     

    The code for the Form.Edit part is still not working .

     

    Even if the Edit collections is not Empty it is not submitting the form when the NEW collection is empty.

     

    I tried testing by changing "||" to "&&".  It does submit the EDIT Collection when I changed to that but when I delete all the records in the collection it does submit like that too without ANY collections data.

     

    If I put the same collections twice in the code it is working but if I put the two collection, it just say missing New Collection.

    Even if EDIT Collection is not there, NEW collection can be submitted but NOT the other way around. 

     

    If(Form.Mode = FormMode.New,
    	If(
     CountRows(
     Filter(NewCollection,
     Or(
     IsBlank(A),
     IsBlank(B),
     IsBlank(C)
     )
     )
     ) > 0,
    	
     Notify(
     "Admin Role is required",
     Error
    	), 
    		
     Notify(
     "Success",
     Error 
     )
    	),
    	
    	Form.Mode = FormMode.Edit,
    	
    	If(
     CountRows(
     Filter(
     NewCollection,
     IsBlank(A) || IsBlank(B) || IsBlank(C)
     )
     ) > 0 ||
     CountRows(
     Filter(
     EditCollection,
     IsBlank(D) || IsBlank(E) || IsBlank(F)
     )
     ) > 0,
     
     Notify(
     "Admin Role is required",
     Error
     ), 
     Notify(
     "Success",
     Error 
     )
    
     );
     
    )

     

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 739 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 268

Last 30 days Overall leaderboard