
Announcements
Hi,
I have a button control which I want to be Disabled by default, and only change to Edit (and therefore be 'clickable') when the following conditions are met. However, there are multiple conditions which could be met - first things first... Here is the current code...
If(
Toggle5.Value = true && !IsBlank(DataCardValue11.Text),
Edit,
Toggle3.Value = true && !IsBlank(ComboBox3.SelectedItems), Edit,
Toggle3.Value = true && Toggle1.Value = true && Len(DataCardValue12.Text) = 6 && Len(DataCardValue10.Text) = 8 && !IsBlank(DataCardValue7.Text) && !IsBlank(DataCardValue8.Text) && !IsBlank(ComboBox3.SelectedItems),
Edit,
Toggle2.Value = true && !IsEmpty(ComboBox2.SelectedItems),
Edit,
Toggle1.Value = true && Len(DataCardValue12.Text) = 6 && Len(DataCardValue10.Text) = 8 && !IsBlank(DataCardValue7.Text) && !IsBlank(DataCardValue8.Text),
Edit,
Disabled
)
What I am struggling with is the Toggle 3 lines in the above.
So if Toggle3.Value is true
AND ComboBox3 IS NOT blank,
allow Edit....
OR
if Toggle3.Value AND Toggle1.Value both are true (ensure the following conditions are evaluated)
AND ComboBox3 IS NOT blank,
AND Len(DataCardValue12.Text) = 6
AND Len(DataCardValue10.Text) = 8
AND DataCardValue7.Text IS NOT blank
AND DataCardValue8.Text IS NOT blank
allow Edit
The difficulty I am facing is that, although the Submit button is disabled by default, when Toggle3 and Toggle1 are set to true, the Submit button goes straight into Edit... but the conditions for WHEN both of these are set to true is not being evaluated...
What am I doing wrong?
Thanks
K.
Skip all the If's and lay out your conditions with Boolean OR's to determine what is valid.
Please consider changing your Formula to the following:
If(
(Toggle5.Value && !IsBlank(DataCardValue11.Text) ||
(Toggle3.Value && !IsBlank(ComboBox3.Selected.Value) ||
(Toggle2.Value && !IsBlank(ComboBox2.Selected.Value) ||
(Toggle1.Value && (Len(DataCardValue12.Text) = 6) && (Len(DataCardValue10.Text) = 😎 && !IsBlank(DataCardValue7.Text) && !IsBlank(DataCardValue8.Text)) ||
(Toggle3.Value && Toggle1.Value && (Len(DataCardValue12.Text) = 6) && (Len(DataCardValue10.Text) = 😎 && !IsBlank(DataCardValue7.Text) && !IsBlank(DataCardValue8.Text) && !IsBlank(ComboBox3.Selected.Value),
Edit,
Disabled
)
Look at it as, if the first line is true, then it will be edit, if the second line is true, then edit...etc.
If any one is true, then it will be edit.
The above can be further simplified, but this is the basic concept.
Also, avoid using IsEmpty as this will not return what you think. Use IsBlank and check the Selected value (note, Value might not be a valid column of your combobox items, so replace with a valid column name in the above.)
I hope this is helpful for you.