Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Trouble populating fields when navigating

(1) ShareShare
ReportReport
Posted on by 84
I have a Comment screen that gets navigated to in two different ways, once form a landing page, and once from another screen where people can review previously edited info. When they navigate to the screen from the landing page, there is a form with an Order number datacard that is populated by sorting orders from a SharePoint list. When they're on the review screen, there is a gallery where they can select an Order, and then a form next to it that is populated with various information like order, etc, as shown below. 
 
When the users click on the 'Post a comment' button above, what I want to happen is to navigate to the Comment screen, and in the form that'a on the Coments scree have the Order field be automatically populated with the Order that's been selected in the gallery/populated in the form. I've tried creating local variables for the selected_po but it's not working. Any help would be appreciated.  
  • Verified answer
    ronaldwalcott Profile Picture
    ronaldwalcott 1,501 on at
    Trouble populating fields when navigating
    In 
    If(varScenario=1,Sort(Distinct(po_holds,PO_Number),SortOrder.Ascending), selected_po)
     
    Use selected_po to lookup the value in the table so something like
    Lookup(tableName, PO_Number = selected_po) or Filter
    Replace selected_po in your If with this because the evaluation of the If needs to produce a record similar to the sort not a single value
  • mterry Profile Picture
    mterry 84 on at
    Trouble populating fields when navigating
    Set(selected_po, galPOHolds.SelectedItems) is causing an error. It says "Incompatiple type. We can't evaluate your formula because the context variable types are incompatible with the types of values in other places in your app." Name isn't valid. SelectedItems isnt' recognized. However, set(selected_PO, galPOHolds.Selected.PO_Number) does not cause an error and appears to be working correctly becuase I placed a text box to test on the Comment page and when I navigate there it is populated accurately (did the same with the varScenario variable and it appears to work correctly too). So the only issue is with the syntax in the ComboBox Items property:
    If(varScenario=1,Sort(Distinct(po_holds,PO_Number),SortOrder.Ascending), selected_po)
    The above gives an error, it says data type. 
  • Suggested answer
    DBO_DV Profile Picture
    DBO_DV 4,430 on at
    Trouble populating fields when navigating
    Hey I would try it like this:
     
    Scenario 1:
    Set(varScenario, 1);
    NewForm(frmComment);
    Navigate(Comment)
     
    Scenario 2:
    Set(selected_po, galPOHolds.SelectedItems); 
    Set(varScenario, 2);
    NewForm(frmComment);
    Navigate(Comment)
    Combobox
    If(varScenario=1,Sort(Distinct(po_holds,PO_Number),SortOrder.Ascending),selected_po)
    This will result in you being able to choose from the selected values of Scenario 2 if you xant them to be selected you have to put it in the Property SelectedITems and Default. 
  • mterry Profile Picture
    mterry 84 on at
    Trouble populating fields when navigating
    Thank you that worked, and I can see the correct order number being passed to the new screen cause I created a text box to test. Now my problem is getting that variable to populate the combo box when navigated to from one screen, and getting the unique list from the sharepoint list when navigating from the landing screen. I tried to set a variable when clicking the button from the landing screen: 
    Set(varScenario, 1);NewForm(frmComment);Navigate(Comment)
     
    Then another scenario when navigating from the Reply screen:
    Set(selected_po, galPOHolds.Selected.PO_Number); Set(varScenario, 2);NewForm(frmComment);Navigate(Comment)
     
    Both those seem to work fine (again testing with text boxes), but the syntax for the Item property of the combo box is giving me an error:
    If(varScenario=1,Sort(Distinct(po_holds,PO_Number),SortOrder.Ascending),selected_po)
     
    Thanks for your help!
  • Suggested answer
    DBO_DV Profile Picture
    DBO_DV 4,430 on at
    Trouble populating fields when navigating
    Hey mterry,
     
    Since you naviagte away from the screen a local variable will not help. 
    You can only use them when you stay on the specific screen. 
     
    You would need a global variable to get it done.
    Set(varItem,Gallery.SelectedItem)
    For example or replace Gallery.SelectedItem with what you have in the forms item property. 
     
    If this solvede your porblem please accept it as solution so others can find it as well. 
    If it helped in any other way consider liking it so we can keep supporting eachother. 

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,691

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 65,019

Leaderboard