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

Check field is filled before update the data in SQL Database

If((!IsEmpty(Dropdown14.SelectedText.Value)||!IsBlank(Dropdown14.SelectedText.Value))&&(!IsEmpty(DataCardValue8)||!IsBlank(DataCardValue8)),(Patch('[dbo].[Sample]',
LookUp( '[dbo].[Sample]', sample_no = DataCardValue1.Text), {status: "Pass",condition:Dropdown14.SelectedText.Value,mark: DataCardValue8.Text})),NotificationType.Error);

 

I put this function in the OnSelect function of my update button, but it seem it will still update the data in SQL database even through the dropdown14 and datacardvalue8 is blank.

How I do it so it will prompt error notification if any one of the field is not filled by user?

1 ACCEPTED SOLUTION

Accepted Solutions
poweractivate
Community Champion
Community Champion

@NeohLooi 

 

We can reproduce this problem if you use IsEmpty on a Value  - IsEmpty is used on a Table not a Value - if you use isEmpty on a Value the way you are doing, it will not behave as you want.

 

Instead of !IsEmpty(Dropdown14.SelectedText.Value)

you should use

 

 

!IsBlank(Dropdown14.SelectedText.Value)

 

 

You must also correct everywhere else you use it incorrectly as !IsEmpty(Something.SelectedText.Value)  to !IsBlank(Something.SelectedText.Value) as well.

 

Check a full working example versus a full non-working example comparison below:

 

EmptyApp9.gif

 

 

 

 

Check sample App attached to this post : EmptyApp9-v1.msapp to play with this above app on your own as well if you want.

 

How to import attached msapp to your environment to play with it:

 

First, save the attached msapp EmptyApp9-v1.msapp to local computer - then:

 

  1.  Navigate with your browser manually to this URL (or just click the following link): https://us.create.powerapps.com/studio/
  2.  Then, Click "Open" on the left side
  3.  Next, Click "Browse" on the right side
  4. Finally, select the msapp file from the window when prompted.
  5. Done

Check if above helps you @NeohLooi .

 

Additional Reference:

Blank, Coalesce, IsBlank, and IsEmpty functions in Power Apps

Syntax

Blank()

Coalesce( Value1 [, Value2, ... ] )

  • Value(s) – Required. Values to test. Each value is evaluated in order until a value that is not blank and not an empty string is found. Values after this point are not evaluated.

IsBlank( Value )

  • Value – Required. Value to test for a blank value or empty string.

IsEmpty( Table )

  • Table - Required. Table to test for records.


 

View solution in original post

4 REPLIES 4
WarrenBelz
Super User
Super User

Hi @NeohLooi ,

I think you can simplify it to the below - it should work

If(
   IsBlank(Dropdown14.Selected.Value) ||
   IsBlank(DataCardValue8.Text),
   Notify("Complete required fields",NotificationType.Error),
   Patch(
      '[dbo].[Sample]',
      {sample_no:DataCardValue1.Text},
      {
         status: "Pass",
         condition:Dropdown14.SelectedText.Value,
         mark: DataCardValue8.Text
      }
   )
)

 

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.

poweractivate
Community Champion
Community Champion

@NeohLooi 

 

We can reproduce this problem if you use IsEmpty on a Value  - IsEmpty is used on a Table not a Value - if you use isEmpty on a Value the way you are doing, it will not behave as you want.

 

Instead of !IsEmpty(Dropdown14.SelectedText.Value)

you should use

 

 

!IsBlank(Dropdown14.SelectedText.Value)

 

 

You must also correct everywhere else you use it incorrectly as !IsEmpty(Something.SelectedText.Value)  to !IsBlank(Something.SelectedText.Value) as well.

 

Check a full working example versus a full non-working example comparison below:

 

EmptyApp9.gif

 

 

 

 

Check sample App attached to this post : EmptyApp9-v1.msapp to play with this above app on your own as well if you want.

 

How to import attached msapp to your environment to play with it:

 

First, save the attached msapp EmptyApp9-v1.msapp to local computer - then:

 

  1.  Navigate with your browser manually to this URL (or just click the following link): https://us.create.powerapps.com/studio/
  2.  Then, Click "Open" on the left side
  3.  Next, Click "Browse" on the right side
  4. Finally, select the msapp file from the window when prompted.
  5. Done

Check if above helps you @NeohLooi .

 

Additional Reference:

Blank, Coalesce, IsBlank, and IsEmpty functions in Power Apps

Syntax

Blank()

Coalesce( Value1 [, Value2, ... ] )

  • Value(s) – Required. Values to test. Each value is evaluated in order until a value that is not blank and not an empty string is found. Values after this point are not evaluated.

IsBlank( Value )

  • Value – Required. Value to test for a blank value or empty string.

IsEmpty( Table )

  • Table - Required. Table to test for records.


 

View solution in original post

@NeohLooi ,

@poweractivate is correct which is why I removed IsEmpty. Also SelectedText is deprecated, so you should use .Selected.

WarrenBelz
Super User
Super User

Hi @NeohLooi ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

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.

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!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,390)