Power Apps ForAll function

 Set(_popup,false);

Set(ResetNewForm, false);


Set(DivisionGalleryViewing,false);

Set(DistrictGalleryViewing,false);

//Set(FacilityGalleryViewing,false);

Set(StateGalleryViewing,false);

Set(CountyGalleryViewing,false);


Set(FacilityVar,Blank());

Set(DateTimeOfDiscoveryVar,Blank());

Set(DateTimeRepToHSEVar,Blank());

Set(PipelineVar,Blank());

Set(QuantityOfReleaseVar,Blank());

Set(QuantityOfReleaseUnitsVar,Blank());

Set(LatLongVar,Blank());

Set(VarShortDesc,Blank());

Set(VarNRCReportable,Blank());

Set(VarNRCReportableJust,Blank());

Set(VarTState,Blank());

Set(VarTStateRep,Blank());

Set(PHMSAYesNoVar,Blank());

Set(PHMSAJustVar,Blank());

Set(StateYesNoVar,Blank());

Set(StateJustVar,Blank());


Clear(ColDivisionSelectedValues);

Clear(ColDistrictSelectedValues);

//Clear(ColFacilitySelectedValues);

Clear(ColStateSelectedValues);

Clear(ColCountySelectedValues);


Clear(ColDistrictSelectedValues1a);

//Clear(ColFacilitySelectedValues1a);

Clear(ColCountySelectedValues1a);


ClearCollect(

    SpillTestData,

    Test

);

If(

    FormModeIs = "Edit"||FormModeIs = "View",

    Set(DateTimeOfDiscoveryVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'Date/Time of Discovery');

    Set(DateTimeRepToHSEVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'Date/Time Reported to HSE');

    Set(PipelineVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).Pipeline);

    Set(FacilityVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).Facility);

    Set(QuantityOfReleaseVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'Quantity of Release');

        Set(QuantityOfReleaseUnitsVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).Units);

    Set(LatLongVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'Latitude/Longitude');

    Set(VarShortDesc,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'Short Description of Release');

    Set(VarNRCReportable,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'NRC Reportable');

    Set(VarNRCReportableJust,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'NRC Reportable justification statement');

    Set(VarTState,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'T-State Reportable');

    Set(VarTStateRep,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'T-State Justification');

Set(PHMSAYesNoVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'PHMSA 30-Day Reportable');

Set(PHMSAJustVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'PHMSA 30-Day reportable justification statement');

Set(StateYesNoVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'State Reportable');

Set(StateJustVar,First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).'State Reportable justification statement');

ClearCollect(ColDivisionSelectedValues1, Sort(Split(First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).Division,";"),Result));

ForAll(ColDivisionSelectedValues1,Collect(ColDivisionSelectedValues,{Title:ThisRecord.Result}));


ClearCollect(ColDistrictSelectedValues1, Sort(Split(First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).District,";"),Result));

ForAll(ColDistrictSelectedValues1,Collect(ColDistrictSelectedValues1a,{Title:ThisRecord.Result}));

/*

ClearCollect(ColFacilitySelectedValues1, Sort(Split(First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).Facility,";"),Result));

ForAll(ColFacilitySelectedValues1,Collect(ColFacilitySelectedValues1a,{Title:ThisRecord.Result}));

*/

ClearCollect(ColStateSelectedValues1, Sort(Split(First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).State,";"),Result));

ForAll(ColStateSelectedValues1,Collect(ColStateSelectedValues,{Title:ThisRecord.Result}));


ClearCollect(ColCountySelectedValues1, Sort(Split(First(Filter(SpillTestData,ID = Gallery1.Selected.ID)).County,";"),Result));

ForAll(ColCountySelectedValues1,Collect(ColCountySelectedValues1a,{Title:ThisRecord.Result}));


//----

ForAll(ColDistrictDropdown,

    If(

        !IsBlank(LookUp(ColDistrictSelectedValues1a, Title = ColDistrictDropdown[@Title])),

        Collect(

            ColDistrictSelectedValues,

            {

                Title: ColDistrictDropdown[@Title],

                Division: ColDistrictDropdown[@Division]

            }

        )

    )

);

/*

ForAll(ColFacilityDropdown,

    If(

        !IsBlank(LookUp(ColFacilitySelectedValues1a, Title = ColFacilityDropdown[@Title])),

        Collect(

            ColFacilitySelectedValues,

            {

                Title: ColFacilityDropdown[@Title],

                District: ColFacilityDropdown[@District],

                Division: ColFacilityDropdown[@Division]

            }

        )

    )

);

*/

ForAll(ColCountyDropdown,

    If(

        !IsBlank(LookUp(ColCountySelectedValues1a, Title = ColCountyDropdown[@Title])),

        Collect(

            ColCountySelectedValues,

            {

                Title: ColCountyDropdown[@Title],

                State: ColCountyDropdown[@State]

            }

        )

    )

);


//-----

);

Comments