cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Robertjde
Helper V
Helper V

Patch from a filtered Gallery

Hello everybody,

I filter my Sharepoint entries in a gallery and would like to save certain entries with the help of a outside button in another Sharepoint list if necessary.
Sometimes my formula works but sometimes it doesn't work either. Entries outside of the gallery (e.g. date) are always saved. What am I doing wrong?


Button OnSelect:
Patch(OPS2_Aktionsliste;Defaults(OPS2_Aktionsliste);{Linie:DropdownProzessLinie.Selected.Result;Erstellungsdatum:DatePicker4_1.SelectedDate;Wann:DatePicker4_1.SelectedDate; Dauer:BodyFrühDauer2.Text;Problem_KorrektiveMaßnahme:LabelFST31.Text})

BodyFrühDauer2 and LabelFST31 are located in the gallery

1 ACCEPTED SOLUTION

Accepted Solutions

SOLUTION

after my gallery (Gal1) is filtered, I insert a button (B1) that opens a popup, in this popup I have the button (B2) for patching. Another gallery (Gal2) is required for patching (not visible to the user).

Gallery (Gal1) filter is controlled by a dropdown box (by date).

 

Provide OnSelect Button B1 with variables:
Set (varFSRecord; Gallery_Gal1.AllItems) ;; Set (Varpopup1; True)

 

Item Gallery (Gal2) shows the variable after pressing button (B1): varFSRecord

 

OnSelect Button B2:
Patch (mySP_Database;
Defaults (mySP_Database);
{Line: Dropdown_Linie.Selected.Result;
Creation date: DatePicker.SelectedDate;
Duration: Gallery_Gal2.Selected.Label_1.Text;
Problem_CorrectiveMeasure: Gallery_Gal2.Selected.Label_2.Text
}
)
;; Set (varpopup1; false)

 

You could also put the variable on the OhChange of the dropdown and thus save yourself the one button, but that was not practical in my case.

 

@RandyHayes Thanks for your help, that gave me the idea with the variable.👍

View solution in original post

6 REPLIES 6
RandyHayes
Super User
Super User

@Robertjde 

If you are doing this outside of the Gallery, then consider the following change to your formula:

Patch(OPS2_Aktionsliste;
    Defaults(OPS2_Aktionsliste);
    {Linie: DropdownProzessLinie.Selected.Result;
     Erstellungsdatum: DatePicker4_1.SelectedDate;
     Wann: DatePicker4_1.SelectedDate; 
     Dauer: yourGallery.Selected.BodyFrühDauer2.Text;
     Problem_KorrektiveMaßnahme: yourGallery.Selected.LabelFST31.Text
    }
)

You need to use the value from the selected row in your gallery in your formula.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes Unfortunately, it only works until I activate the filter via the dropdown box. Means, if the view of the gallery changes, "Problem_KorrektiveMaßnahme" is not saved in the SP list.

RandyHayes
Super User
Super User

@Robertjde 

Since you are doing this outside of the Gallery, you're going to need to be sensitive to the fact that your Gallery may change (i.e. if you then so some filtering).  So, either account for that in any action that will alter the gallery or utilize a snapshot to get the record at the time.

You can do this with a variable on the Gallery OnSelect : UpdateContext({lclRecord: ThisItem})

 

Then change your formula to the following:

Patch(OPS2_Aktionsliste;
    Defaults(OPS2_Aktionsliste);
    {Linie: DropdownProzessLinie.Selected.Result;
     Erstellungsdatum: DatePicker4_1.SelectedDate;
     Wann: DatePicker4_1.SelectedDate; 
     Dauer: lclRecord.BodyFrühDauer2.Text;
     Problem_KorrektiveMaßnahme: lclRecord.LabelFST31.Text
    }
)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes  Unfortunately, that doesn't work either. I added the name of the column from the database to the variable.

 

Is it because of my filter item formula?

 

Gallery OnSelect:

 

UpdateContext ({FSRecord: ThisItem})

 


Button OnSelect

 

Patch(OPS2_Aktionsliste;
    Defaults(OPS2_Aktionsliste);
    {Linie: DropdownProzessLinie.Selected.Result;
     Erstellungsdatum: DatePicker4_1.SelectedDate;
     Wann: DatePicker4_1.SelectedDate; 
     Dauer: FSRecord.Dauer_1;
     Problem_KorrektiveMaßnahme: FSRecord.erste_Störung
    }
)

 

 

Gallery Item:

 

Filter(
    OPS1_Entries_Prozess;
    IsBlank(DropdownProzessLinie.Selected.Result) || IsEmpty(DropdownProzessLinie.Selected.Result) || Linie = DropdownProzessLinie.Selected.Result;
    IsBlank(DropdownProzessDatum.Selected.Result) || IsEmpty(DropdownProzessDatum.Selected.Result) || StartsWith(
        Title;
        DropdownProzessDatum.Selected.Result
    );
    IsBlank(LabeProzessFrühschicht.Text) || IsEmpty(LabeProzessFrühschicht.Text) || StartsWith(
        Schicht;
        LabeProzessFrühschicht.Text
    )
)

 

 

what am I doing wrong?

JoAnneCharlotte
Helper II
Helper II

I'm doing something similar, but what I do is pull the source data from SharePoint list into a collection and then set the collection as the gallery source. But I'm also adding an additional field which is hidden from the users in each row, this field is a boolean field which changes from false to true once a field has changed. Then my patch is using forall and filtering the gallary so it only patches records that have been updated:

 

ForAll(
Filter(
gryTimesheets.AllItems,
tglUpdated.Value = true
),
Patch(
'Project Timesheets',
ThisRecord,
{
'Timesheet Date': dteTimesheets_TimesheetDate.SelectedDate,
Audience: drpTimesheets_Audience.Selected.Audience,
Hours: Value(txtTimesheets_Hours.Text),
'Re-Charge?': drpTimesheets_ReCharge.SelectedText,
Notes: txtTimesheets_Notes.Text,
Status: drpTimesheets_Status.SelectedText,
'Time Period': Text(dteTimesheets_TimesheetDate.SelectedDate, "[$-en-GB]mmm yyyy")
}
)
);

 

This is the code on the tglUpdated control - default value:

 

ThisItem.'Timesheet Date' <> dteTimesheets_TimesheetDate.SelectedDate Or ThisItem.Audience <> drpTimesheets_Audience.Selected.Audience Or ThisItem.Hours <> Value(txtTimesheets_Hours.Text) Or ThisItem.'Re-Charge?'.Value <> drpTimesheets_ReCharge.Selected.Value Or ThisItem.Notes <> txtTimesheets_Notes.Text Or ThisItem.Status.Value <> drpTimesheets_Status.Selected.Value

SOLUTION

after my gallery (Gal1) is filtered, I insert a button (B1) that opens a popup, in this popup I have the button (B2) for patching. Another gallery (Gal2) is required for patching (not visible to the user).

Gallery (Gal1) filter is controlled by a dropdown box (by date).

 

Provide OnSelect Button B1 with variables:
Set (varFSRecord; Gallery_Gal1.AllItems) ;; Set (Varpopup1; True)

 

Item Gallery (Gal2) shows the variable after pressing button (B1): varFSRecord

 

OnSelect Button B2:
Patch (mySP_Database;
Defaults (mySP_Database);
{Line: Dropdown_Linie.Selected.Result;
Creation date: DatePicker.SelectedDate;
Duration: Gallery_Gal2.Selected.Label_1.Text;
Problem_CorrectiveMeasure: Gallery_Gal2.Selected.Label_2.Text
}
)
;; Set (varpopup1; false)

 

You could also put the variable on the OhChange of the dropdown and thus save yourself the one button, but that was not practical in my case.

 

@RandyHayes Thanks for your help, that gave me the idea with the variable.👍

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,189)