cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

ForAll Patch sometimes is not patching all items/records to SharePoint List

Hi,

            So I have a odd intermittent issue. In short, I created a canvas app that field managers can submit store closures. Basically the field manager would submit through the canvas power app.  Then submission would then trigger an email (summary of the stores they submitted) while simultaneously patching the record(s) to a SharePoint list. The user can also submit a reopen request through the app which would update the existing record on the SharePoint list as well.

            This has been working well for the most part for the better half of the year. However, there were a few instances where records are not patching to the SharePoint list. The users did not receive any error messages for those instances.  I recently had a manager submit a store closure through my canvas app.

             However, only 4 out of the 8 records (stores) were patched to the SharePoint list. I did confirm that we received the summary of closures email with all 8 stores. I tested out the submission myself and was able to get all 8 submissions patched to the SharePoint list.  This has happened a few times in the past but it so infrequent and there isn't any pattern that I can think of. However, with that being said, since this is considered a critical app, I want to ensure fix this so we don't run into this issue again.  Any help is appreciated! 

Below is the on select code:

ForAll(
    Update_TBL,
    Patch(
        'Store Closure',
        Defaults('Store Closure'),
        {
            'Store Number':Store_Id,
            Location:Location,
            District:District,
            'District Manager':District_Mgr,
            RVP:RVP,
            'RVP Email':RVPEmail,
            ALPM:ALPM,
            'ALPM Email':ALPMEmail,
            Region:Region,
            'Closure Reason':Close_Reason,
            'Closure Date':Close_Date,
            'Additional Comments':Comments,
            Bopis:BOPIS,
            Curbside:Curbside,
            SDD:SDD,
            SFS:SFS,
            'Reopen Date':Reopen_Date,
            'Submitted Date':Today(),
            'Reopen Time':drop_ReopenTime,
            'Submitter Email':User().Email
        
        }
    )
);
    Navigate(Closure_Success_Screen);
    Office365Outlook.SendEmailV2("xxxxx@xxxx.com","Store Closure - " & Concat(Distinct(Update_TBL,Region),Result &"") & " - " & Today(),"See below for a list of closures. " & "<p>" & " @"& "<strong>" & User().FullName & "</strong>" & " - Once the store(s) has officially reopened, please go back into the Closure App and mark the store(s) as" & "<strong> Opened </strong>" &"<strong><em>" & "<span style='color:#ff0000'><span style='background:yellow'>" &"(even if you previously provided a reopen date and time)."&"</strong></em></span></span>" &"<p>" &"<strong>Note: This is an automated email sent through the Closure App.</strong>" & HtmlText1.HtmlText,{Importance:"Normal", Cc:RVP_EMAIL_Address.Text &";" & ALPM_EMAIL_Address.Text &";"& User().Email &";"& DM_EMAIL_ADDRESS.Text});
    Clear(Update_TBL);

 

5 REPLIES 5

Super User@RandyHayes is the best at explaining what's wrong here, tagging him to ensure he see's your post.

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Sorry, just realized Randy must be on holiday, it has been some time now since he has logged in.

 

Gist of it is ForAll works a lot better inside the patch, as opposed to Parenting it. Unlike programming languages where ForAll loops through records, here it just kind of returns you a table with all the matching records in it.

 

Now if you do ForAll(Patch())) you end up patching over and over again and if somethign goes slowly/gets dropped you can end up losing data. whereas Patch(ForAll()) will pathc in all the matching records at one time, once.

 

Assuming Update_TBL is a table with all the info that is being patched onto your patch list it would look like

Patch(
    'Store Closure',
	ForAll(
    		Update_TBL,
	
        {
            'Store Number':ThisRecord.Store_Id,
            Location:ThisRecord.Location,
            District:ThisRecord.District,
            'District Manager':ThisRecord.District_Mgr,
            RVP:ThisRecord.RVP,
            'RVP Email':ThisRecord.RVPEmail,
            ALPM:ThisRecord.ALPM,
            'ALPM Email':ThisRecord.ALPMEmail,
            Region:ThisRecord.Region,
            'Closure Reason':ThisRecord.Close_Reason,
            'Closure Date':ThisRecord.Close_Date,
            'Additional Comments':ThisRecord.Comments,
            Bopis:ThisRecord.BOPIS,
            Curbside:ThisRecord.Curbside,
            SDD:ThisRecord.SDD,
            SFS:ThisRecord.SFS,
            'Reopen Date':ThisRecord.Reopen_Date,
            'Submitted Date':Today(),
            'Reopen Time':ThisRecord.drop_ReopenTime,
            'Submitter Email':User().Email
        
        }
    ))

 

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Thank you Rob and no worries! So it sounds like since I was parenting ForAll, it was causing occasional records to be lost/dropped through the patch process? That is interesting and makes sense. I'll have to test and let you know if it works! I definitely appreciate your expertise and guidence. 

 

So on the same topic, this Canvas app also allows the manager to view current closures (via a gallery grid) that were patched over to the SharePoint list. The user can update the store closure status from "Closed" to "Open" and submit the changes. This would patch and update the existing record in SharePoint list. However, similar to the issue above, there were at least several instances where the user submitted the update but it failed to patch to the existing SharePoint list. I would say 98% of the submission/updates succeeded but these issues are annoying.

 

Below is the onselect code. I'm thinking maybe it's the way I have written the code?

Patch(
        'Store Closure',
        colGridData

    );

ClearCollect(
    colGridData,
    Filter(
        colGridData,
        StartsWith(
            District,
            DistrictSearch_Input.Text
        ) && (IsBlank(openclose_drop.SelectedItems) || IsEmpty(openclose_drop.SelectedItems) || CurrentStatus.Value = "Opened")
    )
);
Office365Outlook.SendEmailV2(
    "xxxx@xxxxx.com",
    "Store Reopening(s) - " & Today(),
    Concatenate(
        User().FullName,
        " has updated the close store list."
    ) & " Please review the <a href='xxxxxxxx'> SharePoint list </a>" & "to view stores that has been recently reopened." & Re_Open_Email_HTML.HtmlText & RVP_Reopen_Emails.Text & ALPM_Reopen_Emails.Text ,{Importance: "Normal"}
);

Office365Outlook.SendEmailV2(
    "xxxxx@xxxx.com;" & User().Email,
    "Store Reopening(s)",
    "This is a confirmation email of your submission. The BC team has been notified. In the final email, the ALPM and RVP would be copied in this confirmation email." & Re_Open_Email_HTML.HtmlText,
    {Importance: "Normal"}
);
Navigate(Edit_Success_Reopen);
Select(btnLoadData);
Set(
    varGridEdit,
    !varGridEdit
);

Reset(DistrictSearch_Input);

 

On that example is the collection of the griddata /supposed/ to be after the patch?

 

Is

colGridData

a collection of records to be updated, that match exactly ID wise the info in 'Store Closure'? and just need status updates?

 

If so it's actually quite simple

Patch(
    'Store Closure',
            ForAll(colGridData,
                    {   ID:ThisRecord.ID,
                        store closure status column name goes here:"Open"}))
                   

in the above jsut change the store closure status column name goes here, to the name of the status column in your source. This patches everything in your colgrid collection, using ID to match it up against its correct record in the source and updates just the one column to Open

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Hi Rob -I'm having a similar issue as TKO but can't quite seem to figure out the Patch() & ForAll() syntax for my scenario.

 

Basically, I have a collection (ColSubResponses) that is a snapshot of the SharePoint list (EFBSubcoordinatorResponses) that I want to eventually patch to. Users input data and the collection gets updated accordingly, but I've been experiencing similar dropouts when attempting to patch to the collection as TKO described above. See my current code to patch collection that exists in the OnChange of each input box below:

 

//ForAll items in the gallery
ForAll(GalleryHeader.AllItems,

//If a record already exists in collection
    If(
    CountRows(
        Filter(
            ColSubResponses,
            Title = Title2.Text && 
            SharePointIDGroup_Entity = Value(Label_HC_HelperEntityID.Text) &&
            SharePointIDGroup_Child = Value(Label_HC_HelperChildID.Text) && 
            SharePointIDGroup_Grandchild = Value(Label_HC_HelperGrandchildID.Text) && 
            Year = Text(VarCurrentYear)
        )
    ) = 1,

//Patch that record
Patch(ColSubResponses,

LookUp(ColSubResponses, 

Title = Title2.Text && 
SharePointIDGroup_Entity = Value(Label_HC_HelperEntityID.Text) &&
SharePointIDGroup_Child = Value(Label_HC_HelperChildID.Text) && 
SharePointIDGroup_Grandchild = Value(Label_HC_HelperGrandchildID.Text) && 
Year = Text(VarCurrentYear))

,
        {
            Title: Title2.Text,
            'Entity ID': EntityID2.Text,
            Process: LBProcess_2.Text,
            'Question Type': LBQuestionType_2.Text,
            Year: 'Current Year_2'.Text,
            'Current Year Response': Value(SubGroupCurrentResponse2.Text),
            'Previous Year Response': Value(LBpreviousyear_2.Text),
            'Variance %': Variance_2.Text,
            Entity: LBEntityname2.Text,
            Group: Group2.Text,
            'Subcoordinator Name': User().FullName,
            Email: User().Email,
            Question: LBQuestion2.Text,
            'Group 2': SubGroup2.Text,
            SharePointIDGroup_Entity: Value(Label_HC_HelperEntityID.Text),
            SharePointIDGroup_Child: Value(Label_HC_HelperChildID.Text),
            SharePointIDGroup_Grandchild: Value(Label_HC_HelperGrandchildID.Text)
        }
    ),

//Else, create a new record
Collect(
        ColSubResponses,
        {
            Title: Title2.Text,
            'Entity ID': EntityID2.Text,
            Process: LBProcess_2.Text,
            'Question Type': LBQuestionType_2.Text,
            Year: 'Current Year_2'.Text,
            'Current Year Response': Value(SubGroupCurrentResponse2.Text),
            'Previous Year Response': Value(LBpreviousyear_2.Text),
            'Variance %': Variance_2.Text,
            Entity: LBEntityname2.Text,
            Group: Group2.Text,
            'Subcoordinator Name': User().FullName,
            Email: User().Email,
            Question: LBQuestion2.Text,
            'Group 2': SubGroup2.Text,
            SharePointIDGroup_Entity: Value(Label_HC_HelperEntityID.Text),
            SharePointIDGroup_Child: Value(Label_HC_HelperChildID.Text),
            SharePointIDGroup_Grandchild: Value(Label_HC_HelperGrandchildID.Text)
        }
    )
))

 

The final patch to the SharePoint list looks like this:

Patch(EFBSubcoordinatorsResponses, ColSubResponses);

 

I've been playing with the syntax to get me from ForAll+Patch to Patch+ForAll (see below), but keep getting "the datasource is invalid" error and I'm guessing it's to do with the schemas not perfectly matching between the gallery and collection. Any thoughts on an approach that could make this work?  Thanks for your help.

 

Patch(ColSubResponses,

LookUp(ColSubResponses,
        Title = Title2.Text && 
        SharePointIDGroup_Entity = Value(Label_HC_HelperEntityID.Text) &&
        SharePointIDGroup_Child = Value(Label_HC_HelperChildID.Text) && 
        SharePointIDGroup_Grandchild = Value(Label_HC_HelperGrandchildID.Text) && 
        Year = Text(VarCurrentYear),

ForAll(GalleryHeader.AllItems,

        {
            Title: Title2.Text,
            'Entity ID': EntityID2.Text,
            Process: LBProcess_2.Text,
            'Question Type': LBQuestionType_2.Text,
            Year: 'Current Year_2'.Text,
            'Current Year Response': Value(SubGroupCurrentResponse2.Text),
            'Previous Year Response': Value(LBpreviousyear_2.Text),
            'Variance %': Variance_2.Text,
            Entity: LBEntityname2.Text,
            Group: Group2.Text,
            'Subcoordinator Name': User().FullName,
            Email: User().Email,
            Question: LBQuestion2.Text,
            'Group 2': SubGroup2.Text,
            SharePointIDGroup_Entity: Value(Label_HC_HelperEntityID.Text),
            SharePointIDGroup_Child: Value(Label_HC_HelperChildID.Text),
            SharePointIDGroup_Grandchild: Value(Label_HC_HelperGrandchildID.Text)
        }
    )));

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,804)