cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
panand99
Solution Supplier
Solution Supplier

Defaut Selectred items - Combo box- In EditForm (Embedded)

Hi,

 

I want to show defualt value of combo box which is depended on another first combo box field that is too coming from another list.

If I changed  the value of first field then its defualt value is sets but when i opened already save form then its not coming.

 

I am using- On First field (combobox-

OnSelect- ClearCollect(valSelected,{Value:DataCardValue2.Selected.'FullName',CityRequired:DataCardValue2.Selected.City,Id:DataCardValue2.Selected.ID});

 

DataCardValue2 is my first combo box field

CityRequired : I want this to be set(Which is sets successfully when i changed the combobox)

 

On my second field- Items: ValSelected

DefualtSelectedItems: valSelected.CityRequired

 

1 ACCEPTED SOLUTION

Accepted Solutions

@panand99 ,

I assume in all of this that the field is actually updating in the list after submission  (as @RandyHayes asked) - if not, the below is not relevant.

You have also not answered @RandyHayes 's question on whether that are single or multi-select - I will assume single for this exercise.

Firstly, your Items should be

Filter(
   'SPList',
   StartsWith(
      'Name',
      DataCardValue2.Selected.Value
   )
) 

although that only solves invalid searches.
To display the item from the list in your control - two things need to be present

 

  • The value to be displayed (from the field in your list) needs to be present in the "schema" of the control Items - in other words it must be a value that is capable of being selected in the control.
  • As the field you are reading from is of  "complex" type (it is a table with two fields Value and Id), you need to tell the Combo Box what to Display in its DefaultSelectedItems

As it is the Value you want displayed and you are reading from a Table in the source. Your original post alluded to the name of cityrequired - you have now stated it is city, so the DefaultSelectedItems should be actually be

{Value:ThisItem.city.Value}

As a footnote on this you honestly do not need Lookup columns unless you are planning giving users bulk data sheet editing in SharePoint and they cause you more unwanted grief than any other type of field (other than maybe Person) that I know of. This video from Shane Young @Shanescows  is worth watching - I stopped using them a long time ago.

 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

11 REPLIES 11
WarrenBelz
Super User III
Super User III

Hi @panand99 ,

You omitted the important bit for saving - the Update of the Data Card that DataCardValue2 is in - try this for a start

{
   CityRequired:DataCardValue2.Selected.CityRequired
   Id:DataCardValue2.Selected.Id
}

also I would have thought your DefaultSelectedItems should reflect the current field

{CityRequired:ThisItem.CityRequired}

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thanks @WarrenBelz  for your help, but the thing here is it doesn`t work properly with that. Let me provide you all details here.

 

-> I have two lookup fields in spo, 1st is name and 2nd is city.

-> On 1st

OnChange/OnSelect Event- ClearCollect(valSelected,{Value:DataCardValue2.Selected.'Name',City:DataCardValue2.Selected.City,Id:DataCardValue2.Selected.ID});

here DataCardValue2 field is 1st combobox

defaultselecteditems: Parent.Default

Items: Filter('SPList',StartsWith('Full Name',DataCardValue2.SearchText))

the value of name combobox can be changed based on user typing in that combobox field.

 

the 1st field is working fine.

 

Now, on the second 'City' lookup field, I want to show city of 'NAME' (1st lookup field) ,

In my case, if user changes value of 'Name' field, then it shows the 'city' accordingly but the issue arises when i opened the already saved record. it does not show the default value of city based on name which is already seelcted.

 

The formula of second city field is- Items-ValSelected,

Defaultselecteditems- Thisitem.Name:City (If i used that then it will show defualt field but not changing field when i change the name).

if i used valSelected.City, then it will only show me value when i changed the name, but now showing me when i open the already saved form.

 

@RandyHayescan u please help me on this.

Thanks,

 

 

 

 

 

@panand99 ,

I can probably help now you have posted the whole issue, but happy to leave you with @RandyHayes if he is on line.

Dear @WarrenBelz 

 

I didn`t mean like that I don`t need you help/advise. It will very much welcomed. 

 

I just mentioned Randy only for the advise.

RandyHayes
Super User III
Super User III

@panand99 

Jumping in as requested.  @WarrenBelz makes important points about the updating of the values to the list.

So, based on that, my question (which I don't see address in the thread) is are the values from the comboboxes being written to the list properly?  You mention "Which is sets successfully when i changed the combobox" - does this mean that it is written to the form list properly?

 

Also not seen is, what kind of column in your list is Name and City?  You state they are Lookup columns, but are the multi-select lookup, or single value?

 

There is no need for a collection or OnChange/OnSelect action.  This is only going to cause problems.

 

Since you are dealing with Comboboxes your DefaultSelectedItems property needs to MATCH the signature of the Items property for the combboxes or nothing will be selected.

 

Now, before I continue too much, you are basing a formula you have on SearchText - I would believe this is going to cause you a problem as a user could type a Name into the combobox that perhaps does not exist.  Thus your second combobox will not have a value.

I would recommend that we base the second off of the selected value of the first.


Please verify/clarify before we proceed.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Thanks @RandyHayes ,

As you have done the work here (along the path I was heading pretty much), I will leave this with you. I have also just got out of bed, so could not answer until now anyway.

RandyHayes
Super User III
Super User III

@WarrenBelz 

No problem Warren.  I am coming up on bed time going the other direction.  So, if any word from @panand99 please feel free to jump in.  

I'm not sure if you're the night shift or if I am...😂

Have a good day!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
panand99
Solution Supplier
Solution Supplier

Thanks for the help @RandyHayes @WarrenBelz ,

 

I am using search text in combobox because my list contains more than 5000 records and I created an inbuild powerapps app (sharepoint integration) And to provide option to user to search from destination list.

 

My first list is document library where it have 1st lookup column (NAME) and the 2nd one 'City' in selected from same lookup field (sharepoint column settings).

 

Now, if I change the 1st name column value and saves then close the form, it sets the correct city value (lookup from list).

 

The only thing is pending is to it can`t show me the value of city once I changed the name in run time.

 

Thanks again.

 

 

 

Hi @panand99 ,

We can now focus on this -

The only thing is pending is to it can`t show me the value of city once I changed the name in run time.

Sorry if I am repeating a question you have detailed somewhere in your posts, but can you please supply

  • The Items of this Combo Box
  • Its DefaultSelectedItem
  • The Update of the Data Card it is in
  • Its Name
  • The the name and type of field it is writing back to

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,423)