cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
greggpowell
Helper II
Helper II

How to create choices for user in the form of a list inside a text field in a form card.... need some help! Thank!

If I have a form, and the form is pulling data from a selection in a gallery, and I have a “Create New Record” button that blanks out all fields/cards in the form so a new records can be entered…….

 

If I want one of the cards/fields to display parent.Default when an existing record and its associated fields are being displayed.

 

And I want it to display a list of options (choices) in something of a drop down list when the user hits the “Create New Record” button and then selects that field…..

 

I am trying to use this code in the Default field on the advanced tab for the form (image below).

 

If(ThisItem.hva_name = Blank(),

    Choices(Audit_Choice_Tables, audit_choice),

    Parent.Default)

 

So, I created a table (Audit_Choices_Table) in Dataverse where the first column (header name=audit_choice), and I imported that table into the app.

 

There is a second method I attempted – in Dataverse, below tables, there is an option called “Choices” – so I created a “Choices” names “Audit_Choices”

 

But when I just do the code like this:

 

If(ThisItem.hva_name = Blank(),

    Choices(Audit_Choices),

    Parent.Default)

 

I still get an error.

 

The documentation on all of this is set up using all the prebuilt stuff Microsoft has – so it’s hard to translate that into doing it for custom solution.

 

Could use some help... thanks.

 

 

Gregg

Arizona

 

greggpowell_0-1630163631535.png

 

3 REPLIES 3
Drrickryp
Super User
Super User

@greggpowell 

I think you are making it more difficult than it needs to be.  PowerApps forms will do most of the work.  Start with a new Edit form and set the datasource to match the datasource in the Items property of the Gallery. You can use Gallery1.Selected or Lookup(ds, ID=Gallery1.Selected.ID, I prefer the latter.  Then add the fields to the form and let PowerApps create the controls in each card.  For your button to create a new item, the OnSelect property should be NewForm(Form1).  The NewForm() function ignores the Item property of the form as it hasn't been created yet.  

In the Gallery, if you want to edit an item, have an icon with the OnSelect property as EditForm(Form1).  Then the cards and controls will be populated with the values from the selected gallery item automatically.

 

So, Maybe I was not clear in what I am trying to do. The form already works as intended, and it populates based on the field selected in the gallery. But, what I need to do is have the ability to update the form record (row in table). So, I have a button to Create a new form (  code: NewForm()   ), and a button to submit the form once the new form is created (code:   SubmitForm()   ).    BUT - for one of the fields that I am updating - just for that one card - I need it to display what's in the table for that record - UNLESS I create a new form - then I need the card to present a list of options the user can select from if selected and the record is being updated or a new form is being created.    

 

So - my issue is - I need to be able to create a list of options for the user to select from - for that one card / field in the form. Everything else work... I just need to create the choices for the person to chose from when they select that field. Right now, when a user goes to update fields - they have to type everything in from scratch - I need to present a list of options for them to pick from in that one field.

 

That's why I was using the choices command - or trying to anyway. 

Drrickryp
Super User
Super User

@greggpowell 

I may not be understanding but unlock the card and hide the textinput box. Put a Dropdown control into the card, for example Dropdown1, Make the Items property of the dropdown: Audit_Choice_Tables (if this is the name of the table containing your choices.  You may want to include something like "Select an audit choice" as the first Item in the AuditChoiceTable.    Make the Default property of the dropdown:

Coalesce(Parent.Default,"Select an audit choice").  That way, if the Parent.Default is blank as it will be when the form is in New mode, then the dropdown will show Select an audit choice in the window.  
Make the Update property of the card: Dropdown1.Selected.Value

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,266)