
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)
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: -
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