web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch not working whil...
Power Apps
Unanswered

Patch not working while inserting and updating record to sql server

(0) ShareShare
ReportReport
Posted on by 13

Hi, 

I have a table with 15k record in sql server.  and I wanted to updated and insert records using power apps. Please find below code and suggest.

Sometimes records are getting inserted and updated and sometimes not. 

Please suggest.

 

ForAll(
Gallery3.AllItems,
If(
IsEmpty(
Filter(
StatsPackActualInput,
FinancialYear = FinYear And SiteID = SiteIDVar And CostLineGrandParent = CostLineGrandParentVar And Department = DepartmentVar And CostLineParent = CostLineParentVar And CostLineDescription = CostLineDescriptionVar And WeekNumber = Value(TextInput1.Text)
)
),
Patch(
StatsPackActualInput,
Defaults(StatsPackActualInput),
{
FinancialYear: FinYear,
SiteID: SiteIDVar,
Department: DepartmentVar,
CostLineGrandParent: CostLineGrandParentVar,
CostLineParent: CostLineParentVar,
CostLineDescription: CostLineDescriptionVar,
WeekNumber: Value(TextInput1.Text),

Actual: Value(TextInput4.Text)
}
),
Patch(
StatsPackActualInput,
First(
Filter(
StatsPackActualInput,
FinancialYear = FinYear And SiteID = SiteIDVar And CostLineGrandParent = CostLineGrandParentVar And Department = DepartmentVar And CostLineParent = CostLineParentVar And CostLineDescription = CostLineDescriptionVar And WeekNumber = Value(TextInput1.Text)
)
),
{Actual: Value(TextInput4.Text)}
)
)
);
UpdateContext({Popup: true})

Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    @surbhibhandari1 

     

    Can you try to update the expressions to below mentioned expression?

    ForAll(
    Gallery3.AllItems,
    If(
    IsEmpty(
    Filter(
    StatsPackActualInput,
    FinancialYear = FinYear && SiteID = SiteIDVar && CostLineGrandParent = CostLineGrandParentVar && Department = DepartmentVar && CostLineParent = CostLineParentVar && CostLineDescription = CostLineDescriptionVar && WeekNumber = Value(TextInput1.Text)
    )
    ),
    Patch(
    StatsPackActualInput,
    Defaults(StatsPackActualInput),
    {
    FinancialYear: FinYear,
    SiteID: SiteIDVar,
    Department: DepartmentVar,
    CostLineGrandParent: CostLineGrandParentVar,
    CostLineParent: CostLineParentVar,
    CostLineDescription: CostLineDescriptionVar,
    WeekNumber: Value(TextInput1.Text),
    Actual: Value(TextInput4.Text)
    }
    ),
    Patch(
    StatsPackActualInput,
    LookUp(
    StatsPackActualInput,
    FinancialYear = FinYear && SiteID = SiteIDVar && CostLineGrandParent = CostLineGrandParentVar && Department = DepartmentVar && CostLineParent = CostLineParentVar && CostLineDescription = CostLineDescriptionVar && WeekNumber = Value(TextInput1.Text)
    ),
    {Actual: Value(TextInput4.Text)}
    )
    )
    );
    UpdateContext({Popup: true})

     

    Hope this Helps!

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

#2
11manish Profile Picture

11manish 193

#3
Valantis Profile Picture

Valantis 138

Last 30 days Overall leaderboard