cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Patron
Post Patron

Form Submitting Inserting New Item into SP List - How to Detect a 400 Error (Unique SP column)

I have a canvas power app that uses a simple form. The form is always in a formMode.new and it inserts a new item into a SharePoint list. The SharePoint list has a column that requires the data to be unique to the list so there can be no duplicates items for that column.  When I submit the form with a duplicate value for that column, I get a 400 error. What is the best method to detect a 400 error when submitting my form? I have found some examples for using Patch but not for form submission.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Memorable Member
Memorable Member

Re: Form Submitting Inserting New Item into SP List - How to Detect a 400 Error (Unique SP column)

Hi Bolin,

in that scenario before submitting the form check the value that you are passing is already exists or not.

if exits in the List then display popup like Found Duplicate.

else submit the form.

Like that you can check - Set(CheckDuplicate,Lookup(Datasource,FieldName=ValueYouNeedToPass));

then use condition to submitting Form.
if(IsBlank(CheckDuplicate),SubmitForm(FormName),Notify("File Value you are Passing already Present in the Liast , Please Pass the Unique Value"))

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."


View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Re: Form Submitting Inserting New Item into SP List - How to Detect a 400 Error (Unique SP column)

@bolin-stratus 

You might consider the approach of not letting a user submit if there is a duplicate, rather than trying to catch the error and handle it (as error handling is a bit tricky in PowerApps).

 

Set your DisplayMode of your submit button to something similar to this:

If(
    !IsBlank(
        LookUp(YourDataSource, yourUniqueField = theControlWhereSomeoneWouldEnterTheValue.Text, ID)
    ), 
    Disabled, 
    Edit
)

This will lookup the unique value - if there is a record with it, then the button will be disabled.

You could use this same logic on the visible property of a Label that might display "please enter a unique value".

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Memorable Member
Memorable Member

Re: Form Submitting Inserting New Item into SP List - How to Detect a 400 Error (Unique SP column)

Hi Bolin,

in that scenario before submitting the form check the value that you are passing is already exists or not.

if exits in the List then display popup like Found Duplicate.

else submit the form.

Like that you can check - Set(CheckDuplicate,Lookup(Datasource,FieldName=ValueYouNeedToPass));

then use condition to submitting Form.
if(IsBlank(CheckDuplicate),SubmitForm(FormName),Notify("File Value you are Passing already Present in the Liast , Please Pass the Unique Value"))

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."


View solution in original post

Highlighted
Post Patron
Post Patron

Re: Form Submitting Inserting New Item into SP List - How to Detect a 400 Error (Unique SP column)

@VijayTailor  & @RandyHayes  - Thank you for your responses. I am marking this one as the solution. 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (7,231)