cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sean-PA2Rescue
Frequent Visitor

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

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
KroonOfficeSol
Resident Rockstar
Resident Rockstar

@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

View solution in original post

2 REPLIES 2
KroonOfficeSol
Resident Rockstar
Resident Rockstar

@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

View solution in original post

@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!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (3,695)