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 / Network error when usi...
Power Apps
Unanswered

Network error when using Patch function: An error occurred on the server

(0) ShareShare
ReportReport
Posted on by

I am having error Network error when using Patch function: An error occurred on the server. Sometimes the data saved in the excel but most of the time failed. Please assist

 

ForAll(
'Timesheet Gallery'.AllItems,
Patch(
Timesheet_Table,
{
Project: 'Project Dropdown'.SelectedText.Value,
'Person Name': 'Person Dropdown'.SelectedText.Value,
'Enterprise ID':EIDInput.Text,
Role: RoleInput.Text,
Country: CountryInput.Text,
Task: TaskInput.Text,
'Date(Weekly)': DateAdd(Value(DatePicker1.SelectedDate),25,TimeUnit.Hours),
Hours: Value(HoursInput.Text),
Modified: DateValue(ModifiedInput.Text)
}
)
);
Clear(TimesheetLines);
Navigate(TimeEntryConfirmation)

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,951 Most Valuable Professional on at

    Hi @gje0924 ,

    There are a number of things here I will point out.

    Firstly, ForAll() is not designed to be a Loop, although it can work this way with considerable performance penalty as it does an individual Patch for each record. ForAll() creates a Table, which can be patched in one action provided its content is correct. For new records, this is simply a Table with field names and field types matching the list. I have updated your code as below

    With(
     {
     _Date:
     DateAdd(
     DatePicker1.SelectedDate,
     25,
     TimeUnit.Hours
     )
     },
     Patch(
     Timesheet_Table,
     ForAll(
     'Timesheet Gallery'.AllItems As _Gal,
     {
     Project: _Gal.'Project Dropdown'.Selected.Value,
     'Person Name': _Gal.'Person Dropdown'.Selected.Value,
     'Enterprise ID': _Gal.EIDInput.Text,
     Role: _Gal.RoleInput.Text,
     Country: _Gal.CountryInput.Text,
     Task: _Gal.TaskInput.Text,
     'Date(Weekly)': _Date,
     Hours: Value(_Gal.HoursInput.Text),
     Modified: DateValue(_Gal.ModifiedInput.Text)
     }
     )
     )
     )
    );
    Clear(TimesheetLines);
    Navigate(TimeEntryConfirmation)

    and will offer the following in addition: - 

    • You need to get the calculation out of the Patch (hence the With() statement at the top.
    • If any of the coltrols are not in the gallery, remove _Gal. from the reference.
    • If the input in ModifiedInput is not a valid date, the code will fail (and this may actually be the cause of your issue)
    • Finally, Excel is a terrible data source and things that should work at times simply do not.

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard