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

How to set the DefaultSelectItems as Parent.Default on a ComboBox

Hi All

 

Hoping someone can help as I've been struggling with this for hours

 

I have 3 ComboBoxes that I am trying to set the DefaultSelectItems for.

 

Depending on whether the screen is in new mode or edit I'd like the ComboBox to either say 'Find Items" for new mode, or pull the parent value from the gallery if it's in edit mode

 

This formula which works in the InputTextPlaceholder field but not the DefaultSelectedItems field?

If(EditForm1.Mode = New, "Find items", Parent.Default)

Which is frustrating because it looks like the value is there, but it's not really so the user has to select them again before resumbitting the form (as they are required fields)

 

Any help would be appreciated
Thanks all
V


Accepted Solutions
KroonOfficeSol
Level 10

Re: How to set the DefaultSelectItems as Parent.Default on a ComboBox

@VickyW

 

Select the datacard and unlock it. Then put in a label and connect this to the Parent.Default. You will see that the label is empty. And this is offcourse normal behaviour on a new form, because there is not yet a selectedItems written to the database ;-)

 

So there's your problem: you want the default to appear in a view or edit mode. Do This:

If(EditForm1.Mode in [0,2], LookUp('[dbo].[MobilePOLog]', PONumber = Value(Parent.Default)))


In case you want to set a default to a new form then you use a local variable to set the PONumber you like to set as a default. On the button starting the new form you do:

NewForm(YourForm);
UpdateContext({PPONumber:ThisItem.PONumber})

On the Combobox you do:

If(EditForm1.Mode =1,
LookUp('[dbo].[MobilePOLog]', PONumber = PPONumber) ,
LookUp('[dbo].[MobilePOLog]', PONumber = Value(Parent.Default))
)

On the Form.OnSuccess you reset your variable so the next time when you do a new form and don't set the variable there will be no selectedItems. Like

UpdateContext({PPONumber:0}) // on a number
UpdateContext({PPONumber:""}) // on a string

 

I use P in front off the variable to show it's a Input Parameter

 

Still it's strange that the text-number flag appears. This means that in one table the PONumber is an int and in another a varchar. I think you should check this and change this if you still can.

 

Hope this helps.

 

Paul

 


All Replies
VickyW
Level: Powered On

Re: How to set the DefaultSelectItems as Parent.Default on a ComboBox

 
KOM_4410
Level 8

Re: How to set the DefaultSelectItems as Parent.Default on a ComboBox

What values Do you have on the Items property of your combo box? Is "find items" one of them?

Highlighted
KroonOfficeSol
Level 10

Re: How to set the DefaultSelectItems as Parent.Default on a ComboBox

@VickyW

 

I really don't understand what you like to do. 

You should know that the InputTextPlaceholder is just a guiding for the user which is visible when there is no selection. On a new form there is no selection so this text is visible by default. If not, then you probably turned off the search option for the combobox. So it makes no sense to set a formula like that for the InputTextPlaceholder .

 

For the combobox. To set the ComboBox.defaultSelectedItems attribute you have to use the lookup() formula, like:

LookUp(YourTable, ID = Parent.Default)

On a new form there will be no Parent.Default there so this means there is no selection by default.

 

Want to set the combobox to a default on a new Form? Then use this formula:

If(EditForm1.Mode = 1, LookUp(YourTable, ID = YourIDSource), LookUp(YourTable, ID = Parent.Default))

 

Hope this helps,

 

Paul

 

VickyW
Level: Powered On

Re: How to set the DefaultSelectItems as Parent.Default on a ComboBox

Hi @KroonOfficeSol

Thanks for the reply

I do know the InputTextPlaceholder is just a guide. I just couldn't understand why my formula worked in that field and not the one I needed it to, DefaultSelectItems  :/

So I am trying the Lookup function as you suggested. But I cant be doing it right as it's still not populating the ComboBox with the supplier name on that record (it should be showing a selected item of "Jurys" as that's what's on PO 1125 in my table [dbo].[MobilePOLog])

If(EditForm1.Mode = New, LookUp('[dbo].[MobilePOLog]', PONumber = Value(Parent.Default)))


Can you see where my formula is wrong?

PS. I had to convert the Parent.Default to a value otherwise I was getting a mismatch error saying the formula couldn't evaluate as the left was a number and the right was text

Thanks again
V

KroonOfficeSol
Level 10

Re: How to set the DefaultSelectItems as Parent.Default on a ComboBox

@VickyW

 

Select the datacard and unlock it. Then put in a label and connect this to the Parent.Default. You will see that the label is empty. And this is offcourse normal behaviour on a new form, because there is not yet a selectedItems written to the database ;-)

 

So there's your problem: you want the default to appear in a view or edit mode. Do This:

If(EditForm1.Mode in [0,2], LookUp('[dbo].[MobilePOLog]', PONumber = Value(Parent.Default)))


In case you want to set a default to a new form then you use a local variable to set the PONumber you like to set as a default. On the button starting the new form you do:

NewForm(YourForm);
UpdateContext({PPONumber:ThisItem.PONumber})

On the Combobox you do:

If(EditForm1.Mode =1,
LookUp('[dbo].[MobilePOLog]', PONumber = PPONumber) ,
LookUp('[dbo].[MobilePOLog]', PONumber = Value(Parent.Default))
)

On the Form.OnSuccess you reset your variable so the next time when you do a new form and don't set the variable there will be no selectedItems. Like

UpdateContext({PPONumber:0}) // on a number
UpdateContext({PPONumber:""}) // on a string

 

I use P in front off the variable to show it's a Input Parameter

 

Still it's strange that the text-number flag appears. This means that in one table the PONumber is an int and in another a varchar. I think you should check this and change this if you still can.

 

Hope this helps.

 

Paul

 

VickyW
Level: Powered On

Re: How to set the DefaultSelectItems as Parent.Default on a ComboBox

Thanks @KroonOfficeSol

I knew what you were saying had to be right but I still couldn't get it working

So I created a new app and low & behold... your formulas worked!

 

I went back to my app to figure out what was causing the problem, and it's my jazzy formulas in the ITEM property of each of the 3 ComboBoxes -

 

1. The first simply filters to distinct results only:

Distinct('[dbo].[SupplierServices]',Supplier)

 2. The second filters results by what's in the first ComboBox

Filter('[dbo].[SupplierServices]',Supplier=ComboBox1.Selected.Result)

3. And the last one just sorts the employee names in alphabetical

Sort('[dbo].[StaffRegister]'.InitialSurname,InitialSurname)

But if I paste these formulas into the ComboBox ITEM properties it breaks the DefaultSelectedItems?

I can't believe you have to chose between setting a DefautSelectedItem or filtering/sorting
Perhaps I am pasting the forulas into the wrong place?

But that probably needs to be a new question/post

 

Anyway you for helping me get to the bottom of it!
Regards

V

 

 

KroonOfficeSol
Level 10

Re: How to set the DefaultSelectItems as Parent.Default on a ComboBox

@VickyW

 

Change the sort() to SortByColumns() and try if it works then? Maybe the sort gives back only one column off items and not the record/object.

 

Let me know if it works.

 

Paul

VickyW
Level: Powered On

Re: How to set the DefaultSelectItems as Parent.Default on a ComboBox

That works perfectly! Thank you Smiley Very Happy