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

Combo box in edit forms

Hi,

 

I couldn't find the answer to this but i'm hoping it's something simple!

 

I want to use combo boxes for data entry in some edit forms. This is because they are drawing from a long list of options in SharePoint and I would like users to be able to type into them rather than having to scroll through over 100 entries in a drop down control. I have been using drop downs and have them set up so that they default to a "-" on a NewForm, but show the current value when in EditForm, which I would like to preserve.

 

The issue that I am having is that when I add a combo box to the data card I can't get the card's update property to recognise the combo box.selected.value, not can I get the combo box to accept the default of "If(StudentDetailsFrm.Mode=FormMode.New,"-",ThisItem.Programme)"

 

I have tried creating a 'Choice' field type from Sharepoint (as this has the funtionality that I want in PowerApps) but I can't seem to recreate it myself.

 

Any suggestions would be appreciated

 

UPDATE- I have marked a post as the solution, however the whole thread contibuted towards it.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Combo box in edit forms

Hi @SamGibbs,

Do you add the Combo box control within the Department data card rather than outside the Departemnt data card?

Please take a try with the following workaround:

Set the Items property of the Combo box control to following formula:

MasterDeptList.Title

Set the Update property of the Department data card to following formula:

ComboBox1.Selected.Title

then check if the issue is solved.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

11 REPLIES 11
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: Combo box in edit forms

If you have a Choice field in SharePoint, then the default value needs to be an object, not a string (that's how choice columns are stored in SharePoint). The blog post at https://powerapps.microsoft.com/en-us/blog/default-values-for-complex-sharepoint-types/ has more details about this scenario, but for your specific case, you can use this expression in the DefaultSelectedItems property of the combo box control (the control itself, not the card that contains it):

If(
    StudentDetailsFrm.Mode = FormMode.New,
    { Value: "-" },
    Parent.Default)
SamGibbs
Level: Powered On

Re: Combo box in edit forms

Hi,

 

Thanks for the reply. I haven't actually used a choice field in the SharePoint list, it is a single line text field- I knew that the choice field generated a combo-box style data card so I wanted to try and use it as a template to recreate it for my text field, with data values drawn from a seperate list (acting as a look up). I wasn't clear in my original post, apologies.

 

I have tried the formula that you suggested, but this returns a invalid argument error (due to the lack of clarity mentioned above?)

Community Support Team
Community Support Team

Re: Combo box in edit forms

Hi @SamGibbs,

Do you want to provide values for a Single line of text field using Combo box control within the Edit form?

Based on the formula that you provided, I think there is something wrong with the formula that you provided within the DefaultSelectedItems property of the Combo box control.

The DefaultSelectedItems property of the Combo box control is required to provided a record value, but the ThisItem.Programme formula (within the formula that you provided) would return a text value.

I have made a test on my side, please take a try with the following workaround:17.JPG

Note: The Dept column is a Single line of text type column. Within Dept Data card, I remove the original TextInput control, and add a Combo box control to instead of it.

Set the Items property of the Combo box control to following formula:

 

Choices('20181003_case3'.Department)

Note: The '20181003_case3' represents the separated list which the Dept column pulls data from.

Set the DefaultSelectedItems property of the Combo box control to following formula:

 

 

If(
    EditForm1.Mode = FormMode.New,
    {
       '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        Value: "-" 
    },
    {
       '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        Value:Parent.Default
    }
)

On your side, you should type the following formula:

 

 

If(
    StudentDetailsFrm.Mode = FormMode.New,
    {
       '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        Value: "-" 
    },
    {         /* <--  Modify here, type a record value rather than a Text value */
       '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        Value: ThisItem.Programme
    }
)

The GIF screenshot as below:Test1.gif

 

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
SamGibbs
Level: Powered On

Re: Combo box in edit forms

Hi @v-xida-msft,

 

Thank you for looking into this. The formula that you provided works for setting a default on a new form, or picking up the exisiting value when editing.

 

Formula in DefaultSelectedItems = If(Form2.Mode = FormMode.New,{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Value: "-" },{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Value: ThisItem.Department})

 

I couldn't set the combo box items property to Choices('MasterDeptList'.Title) which is the list I want to take the options from. The formula checked says that it has some invalid arguments. However just having Items= MasterDeptList.Title seems to work anyway?

 

The main issue now is that the data card Update property has the error "Name isn't valid. This identifier isnt recognised." Currently DataCard Update= ComboBox1.Selected.Value. What am I missing here as currently the form will not submit.

 

Thanks again

Sam

Community Support Team
Community Support Team

Re: Combo box in edit forms

Hi @SamGibbs,

Could you please share more details about the error message on your side?

Please check if there is a column called Title within your SP list data source (MastreDeptList). Also please check if you have renamed the Title column into another name.

If the issue still exists, please take a try to re-create your app, then check if the issue is solved.

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
SamGibbs
Level: Powered On

Re: Combo box in edit forms

Hi,

 

Do you mean the error message relating to the DataCard Update property?

Capture.JPG

 

I have been using MasterDeptList.Title as a reference in other apps and it has always worked (including in dropdown controls). the combo box control is happy with Item= MasterDeptList.Title, but won't accept Choices in the formula.

SamGibbs
Level: Powered On

Re: Combo box in edit forms

Hi @v-xida-msft

 

I have built a new app to try and test this out. I still can't get it to work.

 

I have realised that the use of Choices in the items property of the combo box, will only work if it is linked to a choice field in sharepoint. I am using a single line of text field as a look up.

 

However, I have got it to the point where a new form defaults to a '-', edit form returns the entry already in the record. I can use the combo box to search and select a desired value, so it's nearly there.

 

The last issue is getting the datacard Update property (currently = ComboBox1.Selected.Value) to accept the combo box defined record. I have included the picture of this error. I have tried making it Update=ComboBox1.Selected but then it is expecting text.error combo.JPG

 

 

Highlighted
Community Support Team
Community Support Team

Re: Combo box in edit forms

Hi @SamGibbs,

Do you add the Combo box control within the Department data card rather than outside the Departemnt data card?

Please take a try with the following workaround:

Set the Items property of the Combo box control to following formula:

MasterDeptList.Title

Set the Update property of the Department data card to following formula:

ComboBox1.Selected.Title

then check if the issue is solved.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

SamGibbs
Level: Powered On

Re: Combo box in edit forms

Hi @v-xida-msft

 

I was adding it into the data card- making the update = ComboBox1.Selected.Title has now resolved the issue.

 

Thank you for your help with this one; it had been bugging me for weeks!

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
Users Online
Currently online: 307 members 5,614 guests
Please welcome our newest community members: