cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
flyte
Level: Powered On

Help With Data and Edit Forms

Using the SharePoint list template, I have an app with the generated BrowseScreen, DetailScreen, and EditScreen,

 

1: I want to de-clutter my edit screen by offloading the "comments" multi-line text boxes off to another page. So I have a comment icon that when OnSelected, it'll Navigate to the "EditComment" screen. I to pass in selected item's comment field as a context variable upon Navigate by identifying the associated column name that PowerApps has generated for me for the comments field on my sharepoint list. 

  1. Navigate(CommentScreen, ScreenTransition.Fade, {Comments: BrowseGallery1.Selected.Vehicle_x0020_Check_x002d_in_x00})

The problem is, if I edit the comments and then go back to the EditScreen, these are not saved/updated when I click the checkmark to save the record. What am I missing here? 

 

2: On my DetailsScreen, how do I get it to automatically adjust the screen's height to accomodate the contents of a multiline text input? The DataCardValue doesn't seem to expand to show all that was entered.

 

Any help would be appreicated

7 REPLIES 7
Meneghino
Level 10

Re: Help With Data and Edit Forms

Hi @flyte

 

I personally find that as soon as you need some flexibility, then it is better to abandon forms and create your own by using the single controls.  You then submit the data via a Patch command that you can customise as you like.  It is also much easier to implement business logic.

 

In your question for example, you would Patch the changes including the comments from the other screen, without even needing a context variable.

 

Let me be more specific.  Say you have a few text inputs, date pickers, drop downs etc. on your first screen and text inputs (multiline) on your second screen.  Then to save the changes you just have a button on the first screen something like this:

MySaveButton.OnSelect = Patch(MyDataSource, MyRecord, {ColumnA: TextInputFirstScreen1.Text, ColumnB: TextInputFirstScreen2.Text, ColumnC: DatePicker1.SelectedDate, ColumnD: TextInputSecondScreen1.Text etc. etc.})

Please let me know if this helps

flyte
Level: Powered On

Re: Help With Data and Edit Forms

Thanks @Meneghino - I agree, this approach is probably much easier. I find the DataCard / DataValue / DataKey stuff to be confusing! Although it is nice that the templates automatically create the Details and Edit screens for you. I think I can leave the details screen as is, but redo the edit screen from scratch and it should be all good.

 

 

flyte
Level: Powered On

Re: Help With Data and Edit Forms

@Meneghino

 

How would I Patch a Person/Group column from a SharePoint list? In the DataForm way, the "Created By" column is not exposed as a field in a SharePoint list data source, however somehow that column is set with the proper user whnen SubmitForm() is called. 

 

How do I do this manually via Patch? I don't even have access to that column to be able to set it?

Meneghino
Level 10

Re: Help With Data and Edit Forms

Hi @flyte

The 'Created By' column should be read-only (as should the 'Created Date/Time', 'Modified By', 'Modified Date/Time' columns)

This is because these are system columns and SharePoint (and CDS) fills in the data automatically using the information of the user who is creating or modifying the records.

If you really want a customisable column, I suggest you create another person type column.

Hope this helps.

flyte
Level: Powered On

Re: Help With Data and Edit Forms

I now have another problem - on my EditScreen, an icon's color is determine by if(IsBlank(...)) of a TextInput that is on the EditComment screen. Now initially this works, but when I return to the EditScreen, the contents of the TextInput on the EditComment screen isn't reset. Using the approach @Meneghino mentioned in another thread by sending a Context variable to a page upon Navigation, I can reset the contents of my controls on the current page. But not on the EditComments page.

 

In otherwords, when my EditScreen becomes visible with a reset requested, how do I trigger a reset for a control on the EditComment screen such that my icon color is properly set?

Meneghino
Level 10

Re: Help With Data and Edit Forms

Hi @flyte  let me outline a general issue then come back to your specific issue at the end.

 

I suspect that your issue is related to the way context variables work in PowerApps.

  1. Context variables are NOT global, they are specific to each screen
  2. You cannot access the value of context variable of a different screen, a variable needs to be defined for every screen where it is used
  3. You can have the same name for a context variables in different screens, but the values will be different/independent in the different screens

If you continue to work with PowerApps it is important to really understand the above.  I suggest you experiment by:

  1. Create a blank app with two screens
  2. On each screen create a button with OnSelect = UpdateContext({MyVariable: MyVariable+1})
  3. On each screen create a text box with Text = MyVariable
  4. Create another button on each screen with OnSelect = Navigate( the other screen, None)

You will see that the two variable values in the two screens are independent.  I am not sure that is how I would have designed PowerApps but this has some advantages (i.e. you can copy screens and not worry about having to rename variables)

 

Now to get back to your specific issue, if you want to reset controls on a screen as you leave it you can set the screen's OnHidden property to

UpdateContext({ResetControls: true}); UpdateContext({ResetControls: false})

If, on the other hand, you want to reset the controls as you navigate to a screen then you can set its OnVisible property to the above.

 

All this will work for any controls on that screen only, and whose Reset property is set to ResetControls

 

Please let me know if this helps

Meneghino
Level 10

Re: Help With Data and Edit Forms

Here is another approach by @v-micsh-msft which could be better in some use cases:

https://powerusers.microsoft.com/t5/PowerApps-Forum/how-to-do-multiple-text-box-clearing-and-dropdow...

 

Basically if you want to trigger the reset when one or more buttons are pressed then you can set the Reset property of any controls to ButtonA.Pressed || ButtonB.Pressed etc. etc.

 

Then it does not matter which screen the controls are in, since ButtonX.Pressed is a global variable!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,157)