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
Unanswered

Network Error when using patch function: The specified record was not found.

(0) ShareShare
ReportReport
Posted on by 22

Hi I'm trying to insert variables into a SQL table via a patch function. The button works fine until I try to capture the User().Email and insert it too.

Patch(
 'assurance.comments',
 Defaults('assurance.comments'), // If varIdea is blank, use default values; otherwise, use varIdea
 {
 assurance_contractid: TextInput6.Text, // Use the selected value from ComboBox1_2
 assurance_comments: 'text metrics input_5'.Text, // Use the value from text input named 'text metrics input_2'
 insert_DateTime: Now(), // Use the current date and time
 assurance_userid: User().Email
 }
);
The SQL table has all the required columns (see photo) and when I remove the assurance_userid: User().Email part it works again it works.SQL table.PNG
 
Can anyone offer any advice?
 
Thanks,
Categories:
I have the same question (0)
  • vaubeee Profile Picture
    533 on at

    Hi @NiiruK ! I assume that you've already made sure that the database column accepts the format you are submitting. The issue could be that the 'get the user's email'-operation is performed parallel inline the patch-operation. Try to set a variable OnStart of the app or OnVisible of the screen that already holds that value:

     

    Set(varUserMail; User().Email)

     

    Patch(
     'assurance.comments',
     Defaults('assurance.comments'), // If varIdea is blank, use default values; otherwise, use varIdea
     {
     assurance_contractid: TextInput6.Text, // Use the selected value from ComboBox1_2
     assurance_comments: 'text metrics input_5'.Text, // Use the value from text input named 'text metrics input_2'
     insert_DateTime: Now(), // Use the current date and time
     assurance_userid: varUserMail
     }
    );

     

    ------------------------------------------------------------------------------------------------------------------------------
    If I have answered your question / helped to solve your problem, please accept as solution and give me a Thumbs up. Thanks! - Remember: you can accept more than one post as a solution.

  • Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @NiiruK ,

     

    What is the datatype of "assurance_userid"? 

    If it is string then it will be inserted.

    If you still face issue try putting value as "Text(User().Email)"

     

    But if you have different datatype then it won't submit.

    To know more about error, you can try the following code:

     

    IfError(
     Patch(
     'assurance.comments',
     Defaults('assurance.comments'), // If varIdea is blank, use default values; otherwise, use varIdea
     {
     assurance_contractid: TextInput6.Text, // Use the selected value from ComboBox1_2
     assurance_comments: 'text metrics input_5'.Text, // Use the value from text input named 'text metrics input_2'
     insert_DateTime: Now(), // Use the current date and time
     assurance_userid: User().Email
     }
     ),
     Notify("Error : " &FirstError.Message, NotificationType.Error, 2000),
     Notify("Success", NotificationType.Success, 1000)
    );

     

    Hope this helps

  • NiiruK Profile Picture
    22 on at

    Forgive me I've altered your code a bit. I've tried to change the column name in SQL to [assurance_user_id] instead of [assurance_userid] to see if that would have an affect but the same issue occurs. I have changed your code and have set the onvisible to: LoggedInUserName instead of varUserMailSQL onvisible.PNG

    When i try this code out i still get the Network error when using Patch function: the specified record was not found.

    POWERAPP record not found.PNG

    Even though there is a record found in the database e.g. 1MC09 at the bottomSQL record.PNG

    and the column is varchar:SQL varchar 2.PNG

  • NiiruK Profile Picture
    22 on at

    I tried you code and thought the lack of errors was promising but I'm still getting the error: record was not found patch error. I'm starting to think this might be a SQL error as the PowerApp code makes sense but just isn't getting executed. I've posted some snippits in the response above from SQL showing I have the column in SQL but there's a potential issue with the column itself. Going to run this by one of the database SME's to see if it's something I've done wrong on the SQL side. Thanks for your answer Powerapp code try.PNG

  • Verified answer
    NiiruK Profile Picture
    22 on at

    All,

     

    Thank you again for your efforts on this.

     

    I've managed to find a solution to this.

     

    When a change was made i.e. adding an additional column to the database table the data connection needed to be dropped and re-added again and the patch is working again.

     

    Hope this helps someone else in a similar situation.

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard