cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Future_Vision
Post Patron
Post Patron

How would I edit a record using original forms?

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?

1 ACCEPTED SOLUTION

Accepted Solutions

I went with this and this seems pretty bulletproof 

 

 

If(IsBlank(newProd),{crfeb_product:Parent.Default},newProd)

 

View solution in original post

20 REPLIES 20
RandyHayes
Super User III
Super User III

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

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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
Super User III
Super User III

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

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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.

@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
Super User III
Super User III

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

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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
Super User III
Super User III

@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

 

 

 

    

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Future_Vision
Post Patron
Post Patron

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)'

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

Top Solution Authors
Top Kudoed Authors
Users online (51,848)