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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to set data source...
Power Apps
Answered

How to set data source and item for an EditForm based on a navigation variable

(0) ShareShare
ReportReport
Posted on by 26

I have a canvas app connected to a SPO list. I have a welcome screen as the first screen that lets the user select a navigation based on if they want to create a new item, search a gallery of all existing items, or edit a known item in the SPO list. The first two are very straight forward and work fine. I'm having trouble using the one FORM screen to edit an item selected from the gallery screen, or edit a known item based on the item ID. The navigation isn't the problem. How to use the same FORM to either edit an item selected from the gallery or edit an item based on the input from an textinput box is the problem. 

I'm probably doing this all wrong, but this is what I've got so far.

In the WELCOME screen I have for the OnSelect for the navigation of the EDIT button:

 

Set(_formNavigation, true);ClearCollect(TTItem, LookUp('TT', ID = 'Edit-TextInput'.Text));EditForm(EditForm1);Navigate(EditScreen, ScreenTransition.None)

 

Other than a delegation warning, this formal has no errors.

For the navigation of the search gallery button, this:

 

Set(_formNavigation, false);Navigate(BrowseScreen,ScreenTransition.None)

 

The BrowseScreen works like a normal browsescreen.

The trouble I'm having is with the editform screen.

The EditForm1 properties are:

DataSource = If(_formNavigation = false, [@'TT'], _formNavigation = true, [@'TTItem'])

Item = TTGallery.Selected

Item currently shows an error because of the confusion from the DataSource. I'm struggling to write the formula for the Item property so that it either uses the item from the Gallery Selected or from the collection for TTItem (TTItem is based off of the user knowing a specific SPO item ID).

I have tried this formula for the Item property for EditForm1:

If(_formNavigation = false, TroubleGallery.Selected, _formNavigation = true, TroubleTicketItem) 

but there is an error with it.

Is this even possible? 
I'm sure I could create another edit screen and set the data source for one or the other, but I was hoping to limit the number of screens

 

Any and all help appreciated!

 

Categories:
I have the same question (0)
  • Verified answer
    KroonOfficeSol Profile Picture
    587 on at

    @Sean-PA2Rescue,

     

    What you are trying is to use the same form from different screens, am I right.

     

    A better approach is to use a record variable from both screens, like:
    Screen 1: ID

    Navigate(EditScreen, None, {TTItem: LookUp(DataSource, id=id)})

    Screen 2: Gallery.OnSelect

    Navigate(EditScreen, None, {TTItem: ThisItem})


     On the EditScreen.OnHidden

    UpdateContext({TTItem: Blank()})

     

     

    On the Form.Item 

    TTItem

     

     

    As long as you use the same datasource for the gallery and Form this will work, this because the variable record has the same schema as your datasource.

     

    Also, you could use this editscreen also for creating new records. Just do:

    NewForm(YourForm); Navigate(EditScreen)

     

    Hope this helps.

     

    Paul

  • Sean-PA2Rescue Profile Picture
    26 on at

    @KroonOfficeSol 

    wow that was so easy! Thank you for your quick help. I was making it way more difficult than it needed to be. 

     

    Thanks again!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard