cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mikemaccarthy
Frequent Visitor

ComboBox - DefaultSelectedItems - But differentiate between New & Edit form

I THINK I have set up correctly. Combobox is populating the necessary fields. I have set up MULTIPLE different DefaultSelectedItems options with differing levels of success.

I have used for DefaultselectedItems

Filter(Accounts,ACCOUNT_NAME2 = Account_Name2.Text)

Usually, I have the same editform1 for New or Edit and in Default I use something like 

If(EditForm1.mode = FormMode.New, “  “, ThisItem.XXXXXX)

 

But with Combobox and DefaultSelectedItems.... I don't seem to have the chance of differencing between New and Edit. 

 

I cant watch another yourtube trying to see a solution. Help please!

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@mikemaccarthy 

Is Account_Name2 IN your form?  I had assumed so, but it sounds like perhaps it is not.

_____________________________________________________________________________________
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

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Randy,

Gold Star!

If(!(EditForm1.Mode = New), LookUp(Accounts, ACCOUNT_NAME2 = Coalesce(Parent.Default, Account_Name2.Text)) ...... Sorted it.

I really have no idea how you fixed. I will have to read up now what " If(! " means of does.

Thanks for your help.

M

 

View solution in original post

11 REPLIES 11
RandyHayes
Super User
Super User

@mikemaccarthy 

Can you clarify what you mean by "I have the same editform1 for New or Edit and in Default I use something like"

What is Default?  Are you referring to the DefaultSelectedItems?

 

Your formula on the DefaultSelectedItems should be: Coalesce(Parent.Default, Filter(Accounts, ACCOUNT_NAME2 = Account_Name2.Text))

 

I hope this is helpful for you.

_____________________________________________________________________________________
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

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi Randy, Thanks for replying. Apologies for not responding quicker. Operating in European time.

I did not explain myself well. So confused, going around in circles.

Comboboxes and DefaultSelectedItems... and nothing in Default.

My Power App has 3 screens, Browse, Details and Edit. No additional Galleries.

If I enter data into the Edit form. All Seems Well. If I go to Browse, Review and Edit, All my data is there properly. Super. Do edits and Sumbit and all is perfect. Now instead of Editing, I hit the "New Button" which I hope brings me to a New Blank Edit Form... The last selected Account_Name2 is populated in the Combo Box. I have to delete this and then search. Workable, but does not inspire confidence.  Hence, I was hoping I could insert some formula like - If(EditForm1.mode = FormMode.New, “  “, ThisItem.XXXXXX) but this does not seem to work.

Help.

Your extra formula with the Coalesce(Parent.Default,   ) was causing an Error - The function 'Coalesce' has some invalid arguments. 

Sorry.

Thanks.

RandyHayes
Super User
Super User

@mikemaccarthy 

No, the formula you tried will not work especially since you are providing a text value in New mode and when not, you are discarding the value of the Parent.Default.

So we need to get your Coalesce statement working properly.

Let's review a couple things:

1) The underlying column of your datacard - what kind of column is it - text, choice, lookup, etc?  And if it is choice or lookup, is it defined to be a single or multiple?

2) What is the Items property of your Combobox?

3) And while we're putting the questions out - what is your Default and Update property for the Datacard?

_____________________________________________________________________________________
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

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thanks.

Underlying Column is -  Text   (Name of Accounts / clients - Sharepoint List)

Item Property - Accounts

Datacard - Default = blank / nothing    Update property = ComboBox1.Selected.ACCOUNT_NAME2

 

Thanks

 

RandyHayes
Super User
Super User

@mikemaccarthy 

Okay...we're almost there.

Set your DataCard Default property back to the original : ThisItem.'Name of Accounts / clients'  (I assume that is the column name from your list)

Set the DefaultSelectedItems property of the combobox1 to:

    LookUp(Accounts, ACCOUNT_NAME2 = Coalesce(Parent.Default, Account_Name2.Text))

The Update property of the datacard is fine.

 

 

_____________________________________________________________________________________
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

Really want to show your appreciation? Buy Me A Cup Of Coffee!

I was praying as I typed......

It seems Ok ....

But...

When you edit a .... not sure of the correct term.... Record from the browse screen and bring you to Edit form... and all seems fine and you can Edit and save etc.

But now you want to creat a NEW record, so on teh browse screen hit the "+" sign goes to Edit Screen.... Empty Page..... EXCEPT the ComboBox is populated with teh name of the last record we were working on. Then need to go to Combo and Delete the last entry and then type in a search.

Dohhhhh!!!!

RandyHayes
Super User
Super User

@mikemaccarthy 

Is Account_Name2 IN your form?  I had assumed so, but it sounds like perhaps it is not.

_____________________________________________________________________________________
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

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Thanks for your time.

I will keep digging.

M

RandyHayes
Super User
Super User

@mikemaccarthy 

Did we solve something???  

Is that control in your Form or outside of it?  If it is outside and you don't wish to include it in the New record creation, then you can also use the form mode in that formula:

    If(!(EditForm1.Mode = New), LookUp(Accounts, ACCOUNT_NAME2 = Coalesce(Parent.Default, Account_Name2.Text))

_____________________________________________________________________________________
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

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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 (2,142)