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

How can I auto populate a drop down box from a record?

Background:

 

I created an app to input client name and if they are indeed a current client or not. (simple 'yes', 'no' drop down). Once someone goes in and fills it out I have the record stored in a sharepoint list and shown in a gallery where they can see all others that were input. When the item in the gallery is clicked it brings me to a formviewer where they can see the info. In this screen there is a button that creates a variable to grab the sharepoint info from the selected gallery item using the sharepoint ID. When the button is clicked I want the fields to autopopulate from the selected variable. The client field is working because it's a text input. The Default for that field is: Variable1.Title  This grabs the selected gallery item, looks at sharepoint and fills in the client's name in a new form.  I can't get the drop down for the field 'current client' to work with the same logic.

 

Is there a way to autopopulate the drop down menu?

 

Thanks in advanced and apologies for the long explanation! 

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@MindfulMike 

If you set the data source and item property of the edit form as above, You will have a combobox in the card for 'Current Client' and the Items property will be Choices([@'SPlist'].'Current Client') . The DefaultSelectedItems should be Parent.Default .  In the case of a new client being entered, the Parent.Default will be blank but if the Edit form is in Edit mode, then the Current Client will be populated with the previously selected value. 

The button on the view form OnSelect should be: EditForm(yourformname);Navigate(youreditscreenname)

The button for entering a new client from the gallery screen should be outside the gallery and its OnSelect should be: NewForm(yourformname); Navigate(youreditscreenname)

Whether your edit form is in New mode or Edit mode is set with the NewForm() or EditForm() functions with the commands that Navigate to the screen containing the form.

If the data source and Item property of your view form and edit form are properly set, there will be no need for a variable. 

View solution in original post

5 REPLIES 5
Drrickryp
Super User
Super User

@MindfulMike 

I think you have made it much more complicated than it needs to be. I'm not sure you need to use a button or a variable to do what you want.  If your gallery and form has SPlist as your datasource and your gallery is Gallery1,  for example, Set the Item property of the form to Lookup(SPlist, ID=Gallery1.Selected.ID).  How you code the dropdown depends on the column type: "current client" is in SharePoint.   

I may have some confusion regarding whether you form is a view form or an edit form as well as when you refer to a dropdown control, do you mean dropdown or combobox?  

@Drrickryp Thank you for the response! I was afraid I was over complicating it, let me answer your question first. 

 

The Item property for the combo box in the edit form is already set to Choices([@'SPlist'].'Current Client') so it gives them a drop own 'yes' or 'no'. The column type in SPlist is Choices.

 

When a person first goes into the app they see a "Create New" and also the gallery of previous input clients. When they select "Create New" they are navigated to a blank edit form. They input data and its saved to SPlist.

 

If they select the item from the gallery they are navigated to a view form where they can see what was previously input. If they want to change the input of that data they can press a button to be brought to a edit form with that info autopopulated so they can change it and save it again to SPlist. I just can't get the combo box dropdown to populate the previous info.

 

Do you think I still may be over complicating it? 

Drrickryp
Super User
Super User

@MindfulMike 

If you set the data source and item property of the edit form as above, You will have a combobox in the card for 'Current Client' and the Items property will be Choices([@'SPlist'].'Current Client') . The DefaultSelectedItems should be Parent.Default .  In the case of a new client being entered, the Parent.Default will be blank but if the Edit form is in Edit mode, then the Current Client will be populated with the previously selected value. 

The button on the view form OnSelect should be: EditForm(yourformname);Navigate(youreditscreenname)

The button for entering a new client from the gallery screen should be outside the gallery and its OnSelect should be: NewForm(yourformname); Navigate(youreditscreenname)

Whether your edit form is in New mode or Edit mode is set with the NewForm() or EditForm() functions with the commands that Navigate to the screen containing the form.

If the data source and Item property of your view form and edit form are properly set, there will be no need for a variable. 

@Drrickryp You are awesome.

 

Ok so when I select an item from Gallery1 and hit the button the has OnSelect(Lookup('SPlist',ID=Gallery1.Selected.ID);EditForm('Form1');Navigate('Screen1')

The info from the Gallery auto populates which is great!

 

 

 

 

Drrickryp
Super User
Super User

@MindfulMike 

I prefer using the Coalesce() function here.  In your case, Coalesce(ThisItem.YourField, variable).  The coalesce function will evaluate values starting from the left side until it finds one that is not blank.  It obviates the need for an If() statement. 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

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