cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PeterDonohue
Advocate II
Advocate II

Patch SP List Field with ID From Gallery Selection

Hey there 🙂

 

I have the following setup

 

Screen Shot 2019-02-21 at 11.53.57 am.png

I'm trying to update my SP list column Interview from No to Yes when the toggle is slid from No (default) to Yes

The form gets it's information from the gallery selected item on the left

 

When I use 

Patch(apx_details,First(Filter(apx_details,ID = apx_gallery.Selected.ID)),{apx_interview: true})

every time I select a gallery item it changes the toggle to yes and updates my sharepoint list 🙂

 

I'm sure it can be done, I'm just racking my brain with it 🙂

 

Thanks 

 

3 REPLIES 3
v-xida-msft
Community Support
Community Support

Hi @PeterDonohue ,

Could you please share a bit more about the Interview column in your SP list? Is it a Yes/No type column?

Where do you put your Patch formula?

I have made a test on my side, and don't have the issue that you mentioned. Please take a try with the following workaround:

Set the OnSelect property of the Toggle control (Toggle1) within your form to following:

 

If(
   Toggle1.Value = true,
   Patch(
apx_details,
LookUp(apx_details, ID = apx_gallery.Selected.ID),
{
apx_interview: true
}
), Patch(
apx_details,
LookUp(apx_details, ID = apx_gallery.Selected.ID),
{
apx_interview: true
}
) )

Or

If(
   Toggle1.Value = true,
   UpdateIf(
         apx_details,
         ID = apx_gallery.Selected.ID,
         {
            apx_interview: true
         }
   ),
   UpdateIf(
         apx_details,
         ID = apx_gallery.Selected.ID,
         {
          apx_interview: true
         }
   )
)

Please take a try with above solution, then check if the issue is solved.

 

If the issue still exists, please consider take a try to re-create a new app based on your SP list, then try above solution again, check if the issue still exists.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The interview toggle is a Yes/No column. I tried both formulae that you described but it doesn't change the behaviour. It still has the same behaviour.

I have my Patch inserted into Oncheck and OnUncheck. 

Think I might change it so the user can go through the list and change the toggles, then hit a submit button and patch all at once maybe?

 

🙂

@PeterDonohueyour issue is that you have those patch actions on OnCheck and OnUncheck.  What you have to remember is that, if you change the gallery record and the "details" change, so do the states of the toggles (based on the data of the record) - SO...your actions will fire at that point.

What @v-xida-msft suggests is more accurate - put the formula on the OnSelect Action.

 

You might want to change it slightly to this:

Patch(apx_details,
      LookUp(apx_details, ID = apx_gallery.Selected.ID),
      {apx_interview: Toggle1.Value}
   )

Since you are always expecting to patch the value back (on or off), there is no need to do any other check with If statements...just simply patch it back BUT on with OnSelect (not the other actions).

 

Hope that helps.

_____________________________________________________________________________________
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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,007)