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 would I edit a rec...
Power Apps
Answered

How would I edit a record using original forms?

(0) ShareShare
ReportReport
Posted on by 634

I have a screen with 4 forms.  All of the fields set a variable either OnChange or the OnSelect of the submit button(I know. This is a bad idea but it is what works right now.

When all of these forms are valid you can submit to the data source, which in this case is CDS, and get dumped on a 'Success' screen. On this 'Success' page I have 2 HTML Text fields which pull from two variables that I set on the previous screen. On this screen I have a button to start the process of filling out the forms for a new record using some code like this.

 

Set(varFormData, Defaults('Tracking')); Navigate('Tracking Form')

 

What I am attempting to do is add an 'Edit' button that will allow me go back to the previous screen and edit all of the values I entered. Just not sure how to do this.  Can someone point me in the right direction?

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Future_Vision 

    Need a few gaps filled in...

    Can you describe more about what you mean by setting a variable on the OnChange and OnSelect?

    Are you performing a SubmitForm? 

    What is the Item property of your form?

    How are the 4 forms connected?

  • Future_Vision Profile Picture
    634 on at

    Most fields are set this way using the OnChange property of the fields

     

    Set(brand1, Brand1_CB.Selected.Brand)

     

    I have one field that is concatenation of the values from other fields. The OnChange property doesn't appear to set the variables so I am currently setting those variables using of the OnSelect property of the Submit button which probably not a best practice.

     

    Forms are submitted as follows:

     

    Patch('Tracking', Defaults('Tracking'), L1_FRM.Updates, L2_FRM.Updates, L3_FRM.Updates, L4_FRM.Updates); Navigate(Success); Set(full, FullPreview_HTML.HtmlText); Set(mcValues, mcPreview_HTML.HtmlText)

     

    ltem property of each form in the screen is 

    varFormData

     

    Does that cover everything?

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Future_Vision 

    So, you're dealing with multiple forms and you are using patch on them.  You are losing the capabilities of your forms with this method.  I would first take a look over my video on how to split forms properly without losing the functionality of the form.

    You should not be dealing with variables for any of this as the form provided full capabilities to provide what you need...but not if you circumvent the process with a Patch.

    In the video, you will see how the forms get all connected with just one variable.  This will be key to what you are trying to do.  The forms will all be in Edit mode by default and so, if your success screen has a button on it to go back and edit, you would simply navigate back.

    By the way - your formula is not determining success...it is just navigating to a screen that say it was a success- what if it failed?  User would still see it was a success.  Forms will provide this ability if you SubmitForm and the OnSuccess and OnFailure action of the form.

    Also, once you use the SubmitForm, you will have access with the LastSubmit property of the form to all of the information you need for your HTML controls, there is no need for variables for any of that.

    With variables, you constantly need to set and update them all over the place - this only makes a simple app a complex one that is difficult to maintain.

     

    Take a look at the video and see how you think that might be of value to you.  I'm here to answer any questions you might have.

  • Future_Vision Profile Picture
    634 on at

    Thanks for the video. That helped a lot. I think I went down the route of using variables because it made it easier in my concatenation formula but I see how this can be a real pain. One issue I am running into is when I select an item from the gallery. It navigates back to the screen with the forms on it but only the 'native' fields for the datacards are populated. My combo boxes do not populate. I'm guessing it has to do with them being custom datacards. The combo boxes in these DC's pull from separate data sources.

  • Future_Vision Profile Picture
    634 on at

    @RandyHayes Any ideas how to get those comboboxes in my custom cards to populate with the record data when I go to edit? Like I mentioned in my previous post, the cards that contain the original fields populate fine. it's these comboboxes giving me trouble.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Future_Vision 

    When you say they are custom datacards, do you mean you added these datacards as custom cards or that you have "customized" (i.e. Unlocked) them?

  • Future_Vision Profile Picture
    634 on at

    They are customized. For example I added the Brand1 datacard from datasource1. I deleted the text field and replaced it with a combobox that references datasource2. Each combobox has its own datasource. In some cases the combobox has both a datasource and uses a variable to populate the DefaultSelectedItem. That's because I built a 'widget' that allows you to patch a new item to the combobox datasource. The combobox refreshes and uses the variable to populate a value

     

    Future_Vision_1-1617993247161.png 

    Future_Vision_2-1617993269173.png

     

    Hope that makes sense.

     

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Future_Vision 

    Makes sense, but perhaps a little over complicated the process.

    But it explains one thing...you have customized the DefaultSelectedItems property of the combobox.

     

    So a couple of questions:

    1) Do you *really* need a combobox?  A combobox should only be used in scenarios where you need the ability to search or have multiple selections.  If you need neither of those features, the I would skip the combobox and use a Dropdown (which the edit form will add for you automatically if you choose that type of control when you add the field).

    2)  What are the following properties:

           Combobox: DefaultSelectedItems 

           Combobox: Items 

           DataCard: Default

           DataCard: Update

     

     

     

        

  • Future_Vision Profile Picture
    634 on at

    Dropdowns have never been an option I can access. Perhaps because the column in the CDS is text? There is no sign of a dropdown in the Insert menu either. That being said the search is nice for some of these lists since there a couple hundred in some of them.

     

    Typical values for a combobox look like this:

     

    Combobox: DefaultSelectedItems  = blank

    Combobox: Items = Sort(Brands, Brand ,Ascending)

    DataCard: Default = ThisItem.Brand1

    DataCard: Update = Brand1_CB.Selected.Brand (this one is a little odd because most of my other comboboxes have update values that look more like Medium_CB.Selected.'Medium (crfeb_medium)'

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Future_Vision 

    When you add a field to a form, one of the options you have is to select the control type.  If you want a dropdown for a text column, you can choose the Allowed Values control type.  It will set your datacard up with a functional dropdown.

    Note: You cannot change this control type once you unlock your datacard.

     

    But, as you state, search is a feature you want, so a combobox is it.

    Now, looking at your properties, the reason you have nothing showing from the record is that you have nothing in the DefaultSelectedItems property.

    You are trying to set the default value using the Default property.  The Default property of a combobox does nothing.  Not even sure why it is there.

    You must set the DefaultSelectedItems (DSI) property on a Combobox.  And, you must set it to a record, not a text value.  The record you set it to must match the record schema of the Items property.  (this is why you should only use a combobox if absolutely necessary).

    So, that said, your Items property appears to be a sorted list of a data entity called Brands.  So, your DSI to be a record that corresponds to that schema.

    Tell me more about the Brands list.  And also what you want displayed in the combobox (assuming Brand), plus if any other controls or values in your app rely on any values from the combobox (beside the Update property - which is fine because your underlying column is a text column).

     

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard