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

Validate existing data before submitting a form/entry

I am building an app based on a SPO list and having an issue with a validation formula.. 

So this is what it should happen when I hit the "checkmark" submit button. Basically saying if an item is entered in these already exist on the list I have (New) .. populate an error message..

 

If(
!IsBlank(LookUp(New,'Dealer #:' = DataCardValue10_1.Text && 'Product:' = DataCardValue14_1.Text && 'Auction Location' = DataCardValue17.Text)),
Notify("An entry containing both " & DataCardValue10_1.Text & " and " & DataCardValue14_1.Text & " and" & DataCardValue17.Text & " already exists in the list." & " Please create a unique entry that does not already exist in the list" , NotificationType.Error),
SubmitForm(EditForm1_1);ResetForm(EditForm1_1)
)

 

The error message I am getting is 

Dina_0-1620159841713.png

now, some additional information it may be good to share.. The field "Auction location" is a look-up field from another list also available on this SPO site and it seems that's the reason why it's not working but not sure.. 

 

Besides this issue, I can't submit the form as well. 

Any help is greatly appreciated.. 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Dina 

Please consider changing your formula to the following:

If(
   LookUp(New, 
       'Dealer #:' = DataCardValue10_1.Text && 
       'Product:' = DataCardValue14_1.Text && 
       'Auction Location'.Value = DataCardValue17.Text,
       true
   ),
   Notify("An entry containing both " & DataCardValue10_1.Text & " and " & DataCardValue14_1.Text & " and" & DataCardValue17.Text & " already exists in the list." & " Please create a unique entry that does not already exist in the list", NotificationType.Error),

   SubmitForm(EditForm1_1)
)

Move the ResetForm(EditForm1_1) to the OnSuccess action of EditForm1_1.  You should never reset a form like that after a submit without validation of success.  You will completely annoy your users if you do because, if they try to submit and there is an error, you would be immediately deleting everything the just typed in.  Moving that to the OnSuccess makes sure that the data is actually successfully submitted before clearing.  If there is an error, the user can still see the data and resolve the issue before losing their work.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
WarrenBelz
Super User
Super User

Hi @Dina ,

Firstly, Lookup columns are not Delegable, but the below should work (note free-typed, so watch commas and brackets etc)

With(
   {
      wNew:
      LookUp(
         New	
         'Dealer #:' = DataCardValue10_1.Text && 
         'Product:' = DataCardValue14_1.Text
      )
   },
   If(
      !IsBlank(
         Lookup(
            AddColumns(
               wNew,
               "Auction",
               'Auction Location'.Value
            ),
            Auction = DataCardValue17.Text
         )
      ),		 
      Notify(
         "An entry containing both " & DataCardValue10_1.Text & " and " & 
         DataCardValue14_1.Text & " and" & DataCardValue17.Text & 
         " already exists in the list." & 
         " Please create a unique entry that does not already exist in the list" , 
         NotificationType.Error
      ),
      SubmitForm(EditForm1_1);
      ResetForm(EditForm1_1)
   )
)

 

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
Super User
Super User

@Dina 

Please consider changing your formula to the following:

If(
   LookUp(New, 
       'Dealer #:' = DataCardValue10_1.Text && 
       'Product:' = DataCardValue14_1.Text && 
       'Auction Location'.Value = DataCardValue17.Text,
       true
   ),
   Notify("An entry containing both " & DataCardValue10_1.Text & " and " & DataCardValue14_1.Text & " and" & DataCardValue17.Text & " already exists in the list." & " Please create a unique entry that does not already exist in the list", NotificationType.Error),

   SubmitForm(EditForm1_1)
)

Move the ResetForm(EditForm1_1) to the OnSuccess action of EditForm1_1.  You should never reset a form like that after a submit without validation of success.  You will completely annoy your users if you do because, if they try to submit and there is an error, you would be immediately deleting everything the just typed in.  Moving that to the OnSuccess makes sure that the data is actually successfully submitted before clearing.  If there is an error, the user can still see the data and resolve the issue before losing their work.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,230)