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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Network error when usi...
Power Apps
Answered

Network error when using Patch function: Field 'Id' is required

(0) ShareShare
ReportReport
Posted on by 71

Hello,

 

I'm experiencing a persistent issue while working with Power Apps and a SQL database. The specific error message I'm encountering is "Network error when using Patch function: Field 'Id' is required." It seems that, even though the 'Id' field should be auto-generated, the error persists.
          

Patch(
 ProjectsRisks,
 {
 ProjectsCatalogId: 2,
 RiskCatalogId: Drp_new_risk_suggested_risk.Selected.Id,
 RiskCategoryId: Drp_new_risk_suggested_risk.Selected.RiskCategoryId,
 RiskScopeId: Drp_new_risk_suggested_risk.Selected.RiskScopeId,
 RiskProcessId: Drp_new_risk_suggested_risk.Selected.RiskProcessId,
 RiskTypeId: Drp_new_risk_suggested_risk.Selected.RiskTypeId,
 RiskSubtypeId: Drp_new_risk_suggested_risk.Selected.RiskSubtypeId,
 RiskTodoTypeId: Drp_new_risk_todo_type.Selected.Id,
 RiskStatusId: Drp_new_risk_status.Selected.Id,
 ProbabilityId: Drp_new_risk_probabilty.Selected.Id,
 ImpactId: Drp_new_risk_impact.Selected.Id,
 PriorityId: Drp_new_risk_probabilty.Selected.Id * Drp_new_risk_impact.Selected.Id,
 Notes: Txt_new_risk_description.Text,
 ExpirationDate: Date_new_risk_expiration.SelectedDate,
 CreatedBy: User().Email,
 CreateDate: Now()
 }
);

Set(riskCreated, First(SortByColumns(Filter(ProjectsRisks, CreatedBy = User().Email),"CreateDate",SortOrder.Descending)).Id
);

Refresh(ProjectsActions); // Esto no hace nada
If(
 !IsBlank(CombinedItems),
 ForAll(
 CombinedItems As action,
 Patch(
 ProjectsActions,
 {
 ProjectsRisksId: riskCreated,
 RiskActionCatalogId: action.riskCatalogId,
 RiskActionTypeId: action.RiskActionTypeId,
 Description: action.RiskAction,
 CancelStateId: 1,
 CreateDate: Now(),
 CreatedBy: User().Email
 }
 )
 ;ForAll(Filter(tasks, ProjectActionIdDynamic = action.varNextId) As task,
 Patch(ProjectsTasks,
 {
 ProjectsActionsId: First(SortByColumns(Filter(ProjectsActions, CreatedBy = User().Email),"CreateDate",SortOrder.Descending)).Id,
 Description: task.Description,
 ExecutionStart: DateTimeValue(task.ExecutionStart),
 ExecutionEnd: DateTimeValue(task.ExecutionEnd),
 TaskResultId: task.TaskResultId,
 CancelStateIdTask: 1,
 CreateDate: Now(),
 CreatedBy:User().Email,
 Notes:task.Notes

 }
 )
 ) 
 ),
 false
);Notify(NotificationType.Success, "El registro ha sido guardado correctamente")
; Navigate(SCR_RISKS_LIST_VIEW)

I am having the erro in this part of the code:

Patch(
 ProjectsActions,
 {
 ProjectsRisksId: riskCreated,
 RiskActionCatalogId: action.riskCatalogId,
 RiskActionTypeId: action.RiskActionTypeId,
 Description: action.RiskAction,
 CancelStateId: 1,
 CreateDate: Now(),
 CreatedBy: User().Email
 }
 )

I've confirmed that the 'Id' field is properly configured in the SQL database, and I'm not manually assigning a value to 'Id' elsewhere in the code.

If anyone in the community has encountered a similar issue or has insights into resolving this problem, I would greatly appreciate your guidance.

Thank you!

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    Id is autogenerated when a new record is created, but its the primary key for identifying which record to update when doing an edit. Since your Patch doesn't include Defaults(datasourcename) as the second parameter you aren't creating new records. IN those cases you need to identify the record you are updating. Id would be one of the ways to do that.

  • galvang Profile Picture
    71 on at

    Hello @Pstork1 , thanks for your answer.
    I just tried to add Defaults(myDataSource) and it didnt work.

     

    You said, " Id would be one of the ways to do that.", how can I do this?

     

    Cheers!

  • Verified answer
    Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    Take a look at these examples in the documentation. You'll notice that all of them use either Defaults or a Lookup in the second position to identify the record to be patched.  Patch function (contains video) - Power Platform | Microsoft Learn If you are patching a record from a gallery you can also just refer to the selected property of the gallery.  

     

    You should also check the limitations section of the SQL connector docs. There are some specific limitations on updating a SQL table.  SQL Server - Connectors | Microsoft Learn

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard