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 / Fetching specific reco...
Power Apps
Answered

Fetching specific record on application startup

(0) ShareShare
ReportReport
Posted on by 6

I'm trying to write an application backed against a sharepoint list. When the application starts I need it to try to find a specific entry in that list and open a form in edit mode against that record. If the record doesn't exist I should instead open the form in new record mode and populate some default values. My record lookup criteria are based on the current user and a date. 

 

I think I can see how to handle most of the flow using OnVisible events on the main form, but I'm drawing a blank on how to use PowerApps to select that initial record. I need to load it into a variable and set the datasource of my edit form to use that variable. If its not set then I can use the new record form instead (using an IF function) with my defaults stored in variables and the relevant fields bound to those variables.

 

So far I've tried the following, which seemed promising but when the form opens it shows as "no datasource provided", despite there being several records with display name "Test  User". I've set the form's datasource to ppStartRecord:

 

Set(ppStartRecord, LookUp(WeeklyActivity, User.DisplayName="Test User"))

 

Any advice on how I can set a variable to a specific sharepoint list entry such that that variable can be the datasource for an edit form would be extremely welcome!

 

Thanks

Kevin

Categories:
I have the same question (0)
  • MVP-Phipps Profile Picture
    3,508 Super User 2024 Season 1 on at

    You can handle this on app start. Set a variable to lookup a record in your sharepoint list based on the logged-in user then wrap this in an if statement. Depending on the variable, if blank then new form else edit form. Which part do you need help writing?

    Please Accept as Solution if it solves your question. Or just give it a Thumbs Up if it is helpful because this can help others.

    LinkedIn: https://www.linkedin.com/in/charlie-phipps-%F0%9F%91%A8%E2%80%8D%F0%9F%92%BB-91338715b/
    YouTube: https://www.youtube.com/channel/UChmFBGU1YKIU91sNMQ7buGg
    Twitter: https://twitter.com/phipps0218

  • kev160967 Profile Picture
    6 on at

    Thanks, I've edited the original post to include what I'm currently trying. For the moment I'm using a static filter in a lookup statement as a proof of concept, but something isn't getting tied together correctly. I'm running the Set/Lookup in the OnVisible handler for my form, and firing this off in preview mode. At the moment  the form is telling me it doesn't have a datasource set. I'm currently experimenting to see if this is due to my Lookup not being called, or it failing in some way

  • Verified answer
    NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    Hi,
    You have to set the datasource property of the form to your list - WeeklyActivity
    and item property to - 
    Set(ppStartRecord, LookUp(WeeklyActivity, User.DisplayName="Test User"))
    or the variable - ppStartRecord
    And FormMode property of the form to If(IsBlank(ppStartRecord), ForMode.New, FormMode.Edit)

  • kev160967 Profile Picture
    6 on at

    Thanks, that makes sense. I'm now getting a different error (No item to display) but I'll play with for a bit as its likely a fault in my query

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard