cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mary_ann
Helper I
Helper I

Check If record already exists else patch?

Hi teams, The problem is I am first checking whether there is any rows already exists in the DB or not, if exist then do nothing but if not exists then patch.

This is what I am doing but don't know why "If" throwing error. As you can see in the screenshot. 
I have tried using CountRows, Lookup, IsEmpty methods but all throwing error on in If condition.

I am desperately looking for the help, yesterday I have looked few articles for the help.
Links : https://powerusers.microsoft.com/t5/Building-Power-Apps/Prevent-a-patch-if-record-already-exists/td-...

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@mary_ann 

Possibly 2 errors, first, you want to notify if the Lookup IS NOT blank and patch if it is.  Also, I think you may have an extra ")" in your formula.  FYI,  I like to use *1 instead of Value in my formulas as a shortcut to convert text to numbers.  Easier to read.  Also writing your formulas out this way will help you find missing or duplicate parentheses. 

 

If(
   !IsBlank(
            Lookup(
                   dbo, project_id=projectIDTextbox2.Text*1
            )
   ), Notify(
             blah,blah
      ),
   Patch(
         dbo, Defaults(
                        dbo
               ), {etc:xxx}
   )
)

 

 

 

View solution in original post

3 REPLIES 3
Drrickryp
Super User
Super User

@mary_ann 

If(IsBlank(Lookup(datasource, etc.

Hey @Drrickryp thanks for the quick response, But it still having same error. Pls check the attached file.

Drrickryp
Super User
Super User

@mary_ann 

Possibly 2 errors, first, you want to notify if the Lookup IS NOT blank and patch if it is.  Also, I think you may have an extra ")" in your formula.  FYI,  I like to use *1 instead of Value in my formulas as a shortcut to convert text to numbers.  Easier to read.  Also writing your formulas out this way will help you find missing or duplicate parentheses. 

 

If(
   !IsBlank(
            Lookup(
                   dbo, project_id=projectIDTextbox2.Text*1
            )
   ), Notify(
             blah,blah
      ),
   Patch(
         dbo, Defaults(
                        dbo
               ), {etc:xxx}
   )
)

 

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

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

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (5,503)