cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
svramkuna
Frequent Visitor

Patch data to SharePoint list

Hi,

 

From the screenshot, I have SharePoint list  "Dates" with columns as 'Title'(Scheduled Dates in gallery named as galDates2ASHS), 'Days', 'Start Time', 'End Time' , 'TrainerName' and 'Trainer Email'. So when the update button is clicked then the data which is present in the gallery(galDates2ASHS) should get stored in "Dates" list for the particular 'reqID'.

 

svramkuna_0-1631173150544.png

 

So, when I am using the below formula for patching the data, previously it used to work fine but from past few days I am not able to update data(i.e. 'Trainer Name' and 'Trainer Email' are not getting storedScreenshot (54).png) into SharePoint list though it is not showing any error , and in suggestion it is showing correct data when I place cursor on formula.

ForAll(
galDates2ASHS.AllItems,
If(
!IsBlank(
LookUp(
Dates,
Title = lblgalDates2TitleASHS.Text And reqID = Value(lblgalStoreCollTitleASHS.Text)
)
),
UpdateIf(
Dates,
Title = lblgalDates2TitleASHS.Text And reqID = Value(lblgalStoreCollTitleASHS.Text),
{
'Trainer Name': drpgalDates2TrainerListASHS.Selected.Title,
'Trainer Email': Dropdown1.Selected.'Email ID'
}
),
Patch(
Dates,
Defaults(Dates),
{
'Trainer Name': drpgalDates2TrainerListASHS.Selected.Title,
'Trainer Email': Dropdown1.Selected.'Email ID'
}
)
)
);

 

Please help me with this issue.

Thanks in Advance.

4 REPLIES 4
RandyHayes
Super User
Super User

@svramkuna 

First - are both the trainer name and email columns text columns, or do you have people columns?

 

Your ForAll is backward in your formula.  ForAll is a function that returns a table - not a For/Next loop.  So, using it as intended, we can have it as the table supplied to a Patch statement.  

Patch is smart enough to know if the primary ID is blank, that it needs to create a record and if it has an ID, then it will update that item.

 

So, your formula can be changed to the following:

Patch(Dates,
    ForAll(galDates2ASHS.AllItems,
        With(LookUp(Dates, Title = lblgalDates2TitleASHS.Text && reqID = Value(lblgalStoreCollTitleASHS.Text)),
           {ID: ID,
            'Trainer Name': drpgalDates2TrainerListASHS.Selected.Title,
            'Trainer Email': Dropdown1.Selected.'Email ID'
           } 
       )
    )
)  

 

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!

Hi @RandyHayes ,

 

Thanks for the reply. Here Trainer Name and Trainer Email are text columns. But when I am trying with this formula I am facing the same issue i.e. Trainer Name and Trainer Email are not getting updated in SharePoint list "Dates". 

RandyHayes
Super User
Super User

@svramkuna 

Tell me about  drpgalDates2TrainerListASHS and Dropdown1:

1) Are these the controls outside of gallery or the one in it?

2) What is the Items properties of the dropdown controls?

_____________________________________________________________________________________
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!

Hi @RandyHayes ,

I am attaching few Screenshots where you can understand Item property of each control.Screenshot 2021-10-28 095148.png

 

The one which is marked with Yellow is Gallery(i.e. galDates2ASHS), which is from "Dates" SharePoint list.

Screenshot 2021-10-28 095511.png

The one with Red colour is 'Trainer Email' which is Dropdown1. It is from "TrainerList".

Screenshot 2021-10-28 095906.png

The one marked in Blue colour is 'Trainer Name' which is another Dropdown i.e. drpgalDates2TrainerListASHS. It is from "TrainerList".

 

So, here when "update" button is clicked then data(Scheduled Dates, Days, Start time, End Time, Trainer Name and Trainer Email)  present in gallery should get stored in "Dates" SharePoint.

 

Thanks in Advance.

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,575)