Hi all,
I've been thinking long and hard for an easy fix for the following scenario but I need some help.
On one of my screens I have 4 toggle buttons to indicate if a certain engine filter has been replaced true/false.
If true, the user needs to indicate how many are replaced and the app will calculate the remaining amount. I have a lookup to a stocklist to show quantity in stock and then minus the number replaced you end up with remaining quantity of stock.
Since I've got 4 toggles with true/false options and the situation that in case true I have to patch the remaining amount and in case false I need to patch the quantity still in stock, I decided to write out the 16 scenarios, like this in case all four toggles are true:
If(ToggleFuelFilters.Value = true && ToggleAirFilters.Value = true && ToggleLubricatingFilters.Value = true && ToggleRacorFilters.Value = true,
Patch('Stock Liquidos',{
Title: "-",
Engine: DDEngine.Selected.Value,
'Fuel Filter 1': Value(RemainingFF1.Text),
'Fuel Filter 2': Value(RemainingFF2.Text),
'Air Filter 1': Value(RemainingAF1.Text),
'Lubricating Filter 1': Value(RemainingLF1.Text),
'Racor Filter 1': Value(RemainingRFilter1.Text)}));
so as you can see, only the remaining values are patched.
The next scenario is as follows where the fourth toggle is set to false:
f(ToggleFuelFilters.Value = true && ToggleAirFilters.Value = true && ToggleLubricatingFilters.Value = true && ToggleRacorFilters.Value = false,
Patch('Stock Liquidos',{
Title:"-",
Engine: DDEngine.Selected.Value,
'Fuel Filter 1': Value(RemainingFF1.Text),
'Fuel Filter 2': Value(RemainingFF2.Text),
'Air Filter 1': Value(RemainingAF1.Text),
'Lubricating Filter 1': Value(RemainingLF1.Text),
'Racor Filter 1': Value(OnboardRacorFilter1.Text)}));
and as you can see for the last option (Racor replaced is false) I patch the quantity still in stock.
This works like a charm and everything is happy and shiney.
However, I now need to create a screen where there are 6 toggle options true/false and for each of those toggles I again need to patch either the remaining amount after replaced (true scenario) or the still onboard quantity (false scenario).
I have done the math and found out this would require to write 64 different scenario's to cater for each and everyone of the toggle scenarios, like all 6 are true, 5 are true, one is false etc. etc.
I am pretty sure that I am currently dealing with it "the hard way" and there must be an easier solution for this.
I was thinking about a patch per toggle, like
if(ToggleFuelFilters.Value = true,
Patch(Stock Liquidos,
'Fuel Filter 1': Value(RemainingFF1.Text),
'Fuel Filter 2': Value(RemainingFF2.Text)),
'Fuel Filter 1': Value(OnboardFF1.Text),
'Fuel Filter 2': Value(OnboardFF2.Text))
and then continue with the next toggle. However I am struggling to make sure that all of the 6 toggles are written to my Sharepoint List in one single record. I have the feeling that if I do the approach above, I will get 6 records in total where the first record only contains the fuel filter information, second record the airfilters information etc. etc.
Who can help my brain-freeze to melt? Perhaps a collection is the way forward or variables? Many many thanks in advance for guidance provided!