Hi community,
I have 2 Comboboxes in a Gallery. When the gallery ist not filtered, the Collection gets updated and the Comboboxed get Updated also. When the gallery is filtered the Patch does not trigger. I do not get it. Here is the code:
Set(
Warten;
true
);;
ClearCollect(
col_Namen;
{
ID: Blank();
Doz: Blank();
Identifier: Blank()
}
);; //Those patches always work
Patch(
Lehrkörper;
ForAll(
Filter(
Gallery_Lehrkörper.AllItems;
(!IsBlank(ComboBox3.Selected.Result))
) As _item;
{
ID: _item.ID;
'Dozent 1': _item.ComboBox3.Selected.Result;
'Ampel 1': "0"
}
)
);;//Those patches always work too
Patch(
Lehrkörper;
ForAll(
Filter(
Gallery_Lehrkörper.AllItems;
(!IsBlank(ComboBox3_1.Selected.Result))
) As _item;
{
ID: _item.ID;
'Dozent 2': _item.ComboBox3_1.Selected.Result;
'Ampel 2': "0"
}
)
);;//Here I read all data into a collection which works fine. This is to test if something was not collected
ForAll(
Filter(
Gallery_Lehrkörper.AllItems;
(!IsBlank(ComboBox3_1.Selected.Result) || !IsBlank(ComboBox3.Selected.Result))
) As _item;
Collect(
col_Namen;
{
ID: _item.ID;
Doz: _item.ComboBox3_1.Selected.Result;
Identifier: 1
};
{
ID: _item.ID;
Doz: _item.ComboBox3.Selected.Result;
Identifier: 0
}
)
);;//This is the first part of the patch. Identifier is the value where I check which combobox was selected. But it does not work when the gallery which is patched is filtered.
ForAll(
col_Namen As _Test;
If(
And(_Test.Identifier = 0;!IsBlank(_Test.Doz));
Patch(
Lehr;
LookUp(
Lehr;
(StartsWith(
_Test.ID;
ID
))
);
{'Dozent 1': _Test.Doz;'Ampel 1':"0"})))
;; Set( Warten;
false)
Solved! Go to Solution.
I setup a test environment and the following is working for me.
Clear(col_Namen);
ForAll(
Filter(
Gallery1.AllItems,
(!IsBlank(ComboBox3.Selected.Value) || !IsBlank(ComboBox5.Selected.Value))
) As _item,
Collect(
col_Namen,
{
ID: _item.ID,
Doz: _item.ComboBox3.Selected.Value,
Identifier: 1
},
{
ID: _item.ID,
Doz: _item.ComboBox5.Selected.Value,
Identifier: 0
}
)
)
Please note the Clear() prior to the ForAll(). Otherwise you will just update the last collection, not overwrite it. Updating it might leave old records that are now filtered out of the gallery. Value vs. Result is just because of the field I'm using to bind the comboboxes to.
IsBlank() works with a string. IsEmpty() tests a collection. I think the second filter on SelectedItems should be IsEmpty() instead of IsBlank()
Thank you for the reply Pstork1. I seems not to be it or i do not get it. When the data is not filtered in the gallery, everything works fine. When the data is filtered in the gallery it does not Update the values in the comboboxes altough the IDs on col_namen where I collect the names and IDs for the values to patch are in there.
Sorry, the current code isn't what you first posted. The original post had a reference to !IsBlank(ComboBox3.SelectedItems), which will always evaluate to True even if nothing has been selected. That logic skews the collection and effects your results. But in the current code its been changed to !IsBlank(ComboBox3.Selected.Result). As a reminder this was the original code posted.
Thank you for your help. You are right. I Wanted to make it more readable and Posted a better Version. The problem I have still applies. Do you have and ideal How to solve it?
Could you provide a bit more detail on your setup?
1) Are the comboboxes inside or outside the gallery?
2) What kind of field are they bound to?
I setup a test environment and the following is working for me.
Clear(col_Namen);
ForAll(
Filter(
Gallery1.AllItems,
(!IsBlank(ComboBox3.Selected.Value) || !IsBlank(ComboBox5.Selected.Value))
) As _item,
Collect(
col_Namen,
{
ID: _item.ID,
Doz: _item.ComboBox3.Selected.Value,
Identifier: 1
},
{
ID: _item.ID,
Doz: _item.ComboBox5.Selected.Value,
Identifier: 0
}
)
)
Please note the Clear() prior to the ForAll(). Otherwise you will just update the last collection, not overwrite it. Updating it might leave old records that are now filtered out of the gallery. Value vs. Result is just because of the field I'm using to bind the comboboxes to.
User | Count |
---|---|
122 | |
87 | |
86 | |
75 | |
67 |
User | Count |
---|---|
214 | |
181 | |
137 | |
96 | |
83 |