Hi everyone!
I have a Sharepoint list and a PowerApp.
On my Sharepoint List I have 2 columns: Director and Movie. An example of a record that has been entered from the App to the List, is Stanley Kubrick and Eyes Wide Shut.
Now the next time someone uses the App I want to prevent this duplicate selection from being patched to the list.
Is there anyway that I can code the patch function so it would prevent a duplicate selection like this from being push and return an error message saying "item already exists"?
Many thanks !!
Milky
Solved! Go to Solution.
You can look at the trad below;
https://powerusers.microsoft.com/t5/Building-Power-Apps/Check-if-record-exist/td-p/377121
I added the patch bit:
If(CountRows(Filter(DataSource,Name = Textbox.Text)) > 0,"Exist",
Patch({...})
Hey @milky_bar_may
Hi @milky_bar_may ,
Do you want to prevent updating with duplicated record?
Whether do you want to prevent updating with record that "doesn't have the same value in both Director field and Movie field" or "doesn't have the same value in Director field or Movie field"?
1)If you do not want record like this to enter in (Stanley Kubrick and Eyes Wide Shut):
If(CountRows(Filter(DataSource, Director=DirectorInput.Text && Movie=MovieInput.Text))>0,Notify("Record already exists", NotificationType.Error), Patch(DataSource,Defaults(DataSource),{Director: DirectorInput.Text, Movie: MovieInput.Text}))
2) If you do not want record like this to enter in (Stanley Kubrick ,....) or (....,Eyes Wide Shut):
If(CountRows(Filter(DataSource, Director=DirectorInput.Text || Movie=MovieInput.Text))>0,Notify("Record already exists", NotificationType.Error), Patch(DataSource,Defaults(DataSource),{Director: DirectorInput.Text, Movie: MovieInput.Text}))
Except using countrows function, you could also consider IsEmpty to justify.
For example:
If(!IsEmpty(Filter(DataSource, Director=DirectorInput.Text && Movie=MovieInput.Text)),Notify("Record already exists", NotificationType.Error), Patch(DataSource,Defaults(DataSource),{Director: DirectorInput.Text, Movie: MovieInput.Text}))
Best regards,
You can look at the trad below;
https://powerusers.microsoft.com/t5/Building-Power-Apps/Check-if-record-exist/td-p/377121
I added the patch bit:
If(CountRows(Filter(DataSource,Name = Textbox.Text)) > 0,"Exist",
Patch({...})
Hey @milky_bar_may
Hi @milky_bar_may ,
Do you want to prevent updating with duplicated record?
Whether do you want to prevent updating with record that "doesn't have the same value in both Director field and Movie field" or "doesn't have the same value in Director field or Movie field"?
1)If you do not want record like this to enter in (Stanley Kubrick and Eyes Wide Shut):
If(CountRows(Filter(DataSource, Director=DirectorInput.Text && Movie=MovieInput.Text))>0,Notify("Record already exists", NotificationType.Error), Patch(DataSource,Defaults(DataSource),{Director: DirectorInput.Text, Movie: MovieInput.Text}))
2) If you do not want record like this to enter in (Stanley Kubrick ,....) or (....,Eyes Wide Shut):
If(CountRows(Filter(DataSource, Director=DirectorInput.Text || Movie=MovieInput.Text))>0,Notify("Record already exists", NotificationType.Error), Patch(DataSource,Defaults(DataSource),{Director: DirectorInput.Text, Movie: MovieInput.Text}))
Except using countrows function, you could also consider IsEmpty to justify.
For example:
If(!IsEmpty(Filter(DataSource, Director=DirectorInput.Text && Movie=MovieInput.Text)),Notify("Record already exists", NotificationType.Error), Patch(DataSource,Defaults(DataSource),{Director: DirectorInput.Text, Movie: MovieInput.Text}))
Best regards,
Hi @v-yutliu-msft , @yashag2255 , @eka24
Many thanks to you all for the responses. Each worked beautifully.
Sorry for the delay in responding, had an unfortunate stay in a hospital.
Many thanks again!
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
181 | |
52 | |
41 | |
39 | |
33 |
User | Count |
---|---|
261 | |
81 | |
71 | |
69 | |
66 |