Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Unanswered

Unable to patch the OriginalEndDate

Posted on by
Hi 
I have a gallery and I am trying to patch and update the fields in the gallery.
 
I used the below code 
Reset(Inp_Cluster_Drp);
 
ForAll(
    inprogresslis As x,
    If(
        x.status = "New",
        // If the record does not exist, create a new one
        Patch(
            'FTE Draft Data',
            Defaults('FTE Draft Data'),
            {
                'Employee NO': x.'Employee NO', // Use fields from the gallery item
                'Cluster/Function': x.'Cluster/Function',
                Program: x.Program,
                'Full Name': x.'Full Name',
                'Budget Code': x.'Budget Code',
                'FTE(%)': x.'FTE(%)',
                OriginalEndDate: If(
                    IsBlank(x.OriginalEndDate) || Len(x.OriginalEndDate) <> 10,
                    Blank(), // Leave blank if the date format is incorrect
                    Date(
                        Value(Mid(x.OriginalEndDate, 7, 4)),  // Year
                        Value(Mid(x.OriginalEndDate, 4, 2)),  // Month
                        Value(Left(x.OriginalEndDate, 2))     // Day
                    )
                ),
                'Month and Year': x.'Month and Year'
            }
        ),
        // If the record exists, update the existing one using ThisRecord directly
        Patch(
            'FTE Draft Data',
            LookUp('FTE Draft Data', ID = x.rowno), // Update the current item in the gallery
            {
                'Budget Code': x.'Budget Code', // Refer to combo box selection
                'FTE(%)': x.'FTE(%)',
                OriginalEndDate: If(
                    IsBlank(x.OriginalEndDate) || Len(x.OriginalEndDate) <> 10,
                    Blank(), // Leave blank if the date format is incorrect
                    Date(
                        Value(Mid(x.OriginalEndDate, 7, 4)),  // Year
                        Value(Mid(x.OriginalEndDate, 4, 2)),  // Month
                        Value(Left(x.OriginalEndDate, 2))     // Day
                    )
                )
            }
        )
    )
);
 
Refresh('FTE Draft Data');
ClearCollect(FTECollection, 'FTE Draft Data');
 
// Show success notification after the patch operations
Notify("Records Saved to Draft Successfully", NotificationType.Success, 3000);
Set(vboolflag, true);
Clear(inprogresslis);
 
please guide me how to fix it.
 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard