Shane
Shane

Reputation: 397

PowerApps - autofill date for newform

Using PowerApps, how can I get the current date to be autofilled into a new form?

Does the code go into the IconNewItem1 function from the parent BrowseScreen1?

NewForm(EditForm1);Navigate(EditScreen1,ScreenTransition.None)

as something like ...

BrowseGallery1.Selected.Date = Now 

Or does the code go in the EditScreen1 / EditForm1 area as a rule?

Any guidance or suggestion would be appreciated.

Upvotes: 0

Views: 3890

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87258

You would do that in the form itself (or the date picker control of the form). Select the card that has the date value, and in the right-side pane select the 'Advanced' tab. You'll need to unlock the card to change the properties, and when you do, change the Default property of the card from

ThisItem.DateTimeColumn

to

If(EditForm1.Mode = FormMode.New, Now(), ThisItem.DateTimeColumn)

Where DateTimeColumn would be replaced with the name of the column in your data source, and EditForm1 would be replaced with the name of the form control.

Upvotes: 2

Related Questions