web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to check if a reco...
Power Apps
Unanswered

How to check if a record exists in a sharepoint list with powerapps

(0) ShareShare
ReportReport
Posted on by 83

Hi, 

 

I have a power apps form that allows me to add a new record to our SharePoint list.

 

The submit button uses this logic

If (EditScreen_1_Form.Valid,Navigate(BrowseScreen_1,ScreenTransition.None));
SubmitForm(EditScreen_1_Form);
Refresh(xxxxxx_V2);

 

The record adds the following: name, project, from(dates) & to(dates). 

 

 

project .png

 The problem we have is, currently I can submit the same record with dates that can overlap. so for example I can submit a record name, project, and with dates between January 31, 2022 - July 10th, 2023. This is not what I want. I want the form to present a pop-up alert saying, this record already has these dates, please choose different dates. 

 

 

I'm not sure how to go about this. I would be grateful for some support on this

 

 

Categories:
I have the same question (0)
  • Sanshubh Profile Picture
    512 on at

    Hi @shar27 
    You can use Filter Function to check that Record with same date Exist in Sharepoint OR not. and then use CountRows to check if any exist then Show Wrror massage

     

     

    If(
    	CountRows(Filter(ListName,From = DatePicker1.SelectedDate))>0,
    	Notify("Does Exist")
    )

     

     

  • TimBarnes97 Profile Picture
    21 on at

    Try this

     

    If(!IsBlank(Lookup(##DATASOURCE##, ##DateColumnName## = ##DateInputControlName##, ##DateColumnName##)), Notify("Sorry, This data is unavailable",NotificationType.Warning), If(EditScreen_1_Form.Valid,Navigate(BrowseScreen_1,ScreenTransition.None));
    SubmitForm(EditScreen_1_Form);
    Refresh(xxxxxx_V2);

     

    Let me know how you get on. Essentially here you are looking up the datasource to see if the date column returns another record with the same date specified or not. If it does, it notifies with an error. If it doesn't, it the goes through with your original ifstatement to make sure it's valid. 

     

    Hope this helps.

  • TimBarnes97 Profile Picture
    21 on at

    You can also change the lookup to return different columns, so for example instead of it just returning a date there, you could change the column to name which would return the name of the last person to have booked the date. 

     

    Best thing to do is to play around with the lookup function to start with by mixing it around in a text label. Then when you have a return of what you want, use that in an if statement along with IsBlank, or IsMatch for example. 

  • shar27 Profile Picture
    83 on at

    Will the condition catch the overlap in dates? 

     

    sharepoint list dates = 04/04/23 - 06/08/23

    form submit = 06/05/23 -   06/07/23

    should throw an error as the record(person) is already engaged within that time period. 

  • TimBarnes97 Profile Picture
    21 on at

    For over a specified period, Using the above reply @SanshubhLubal  would be the most efficient way. Very clever I must say :). 

  • shar27 Profile Picture
    83 on at

    where i would be putting that?

     

    my submit button has this logic

     

     

    If (EditScreen_1_Form.Valid,Navigate(BrowseScreen_1,ScreenTransition.None));
    SubmitForm(EditScreen_1_Form);
    Refresh(Ringfence_V2);

     

  • Talha_Dar Profile Picture
    870 Super User 2024 Season 1 on at

    Hi @shar27,

     

    Give it a try and see if it helps in achieving the desired outcome.

     

    If(
     First(
     Filter(
     listName,
     dateCollumnName = DatePickerFieldName.SelectedDate,
     projectColumnName = ProjectFieldName.Text,
     // if you want to check for more column add more conditions
     )
     ).anyColumnContainingTextValue = Blank(),
     Notify("Data Does Not Exist"),
     Notify("Data Exist")
    );

     

     

    If you found my answer helpful, please consider giving it a thumbs-up or a like. Your feedback is greatly appreciated!

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • Talha_Dar Profile Picture
    870 Super User 2024 Season 1 on at

    You can replace the `Notify("Data Does Not Exist")` statement with your own logic to be executed when no duplicate record is found. Customize this part of the code with your specific actions, such as displaying a message, logging an event, or performing any other desired operations based on your application's requirements.

  • Sanshubh Profile Picture
    512 on at

    Add this Logic on Submit button

     

    If(
    	CountRows(Filter(ListName,From = DatePicker1.SelectedDate))>0,
    	Notify("This Record Already Exist"),
    	If(
    		EditScreen_1_Form.Valid,
    		Navigate(BrowseScreen_1,ScreenTransition.None)
    	);
    	SubmitForm(EditScreen_1_Form);
    	Refresh(Ringfence_V2);
    )

     

  • shar27 Profile Picture
    83 on at

    Would this catch overlap in dates rather than specific dates? and what happens to my submit button logic. Where i am putting the filter logic?

     

    EXAMPLE

    sharepoint list dates = 04/04/23 - 06/08/23

    form submit = 06/05/23 -   06/07/23

    should throw an error as the record(person) is already engaged within that time period. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard