cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AGroegelich
Helper III
Helper III

Setting default values in new form

Hi All,

 

I am new to PowerApps and struggling with the NewForm modus.

 

I have created an EditForm for modifying records. It has a few fields from the primary table and two dropdown boxes for related tables. My data source is an Excel sheet with several tables. My EditForm is working fine for modifying records.

 

But when I try to add a new record I have a few problems.

  1. One particular field of the primary table needs to be filled with a default value.
  2. The dropdown boxes are not cleared and are still pointing to a value of the previous record a viewed in edit mode. I would like to point them to the first item of the list which says something like “Make a selection”.

 

Default property of the DataCards of these fields says ThisItem.<MyField>. It is my understanding that this is cleared in FormMode.New, which makes sense. However I would like to make that conditional base on te FormMode.

 

So my questions are:

  1. Is there a way to find in what mode the EditForm is? I tried to figure out in the documentation but didn’t find it yet.
  2. Is there a better way to let dropdown boxes to the first item then setting the default property?
  3. Is there a better approach then what I am trying to do right now?

 

7 REPLIES 7
eka24
Super User
Super User

  1. Is there a way to find in what mode the EditForm is? I tried to figure out in the documentation but didn’t find it yet.

  Form.Mode=FormMode.Edit   (You can use if codintion for this)

     2. Is there a better way to let dropdown boxes to the first item then setting the default property?

To avoid Default Selection, Delete the first item on your excel sheet so that it will be blank (Dropdown always   default to the first item on the list

  1. Is there a better approach then what I am trying to do right now?

Try the above and get back if there are issues

 

Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.

 

Hi eka24,

 

Thank you. Something like

If(MyForm.Mode = FormMode.New;MyGlobalVariable;Parent.Default)

is working fine in the default porperty of that particular field.

 

To avoid Default Selection, Delete the first item on your excel sheet so that it will be blank (Dropdown always   default to the first item on the list

Well that is the problem. The don't  😐 In my case the first item states "Select an item" but that is the same idea as a blank item. But for some reason they don't select the first item in the list.

 

 

So is it that the problem left is the dropdown?
If so then, go by what i said then insert a label above the Dropdown that says "Make a Selection".

 

 

Unfortunate, that doesnt' work. You mentioned that a dropdown always defaults to the first item on the list. That is not happning in my app. But you made me thinking. It can be caused by me, because I have changed  the code in the default property. Going to check that.

 

Check want I meant in the Attached. Make a selection would just be in a label not part of the dropdown values.Excel TableExcel Table

 

DropDown.JPG

 

Hi eka24,
I am greatful for your effort for helpning me. I tried what you meant with the empty row, but that isn't the problem.

For some reaon my dropdown box doesn't select the first item. It remembers the value of the record viewed in the form before adding a new record. Maybe I have found a solution, trying that right now.

Well with a lot of try and error I figure it out myself. In the default property of the DataCardValue I put this code:

If(MyForm.Mode = FormMode.New; LookUp(Groups; GroupID = "0"; Name); LookUp(Groups; Name = ThisItem.Group; Name))

 

Group is the name of the field of the primary table and Groups is the list in the dropdown box. I tried to put Parent.Default in the Else branch of the statement but that doesn't work.

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,772)