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 / Inserting a record in ...
Power Apps
Unanswered

Inserting a record in SQL table from PowerApp

(1) ShareShare
ReportReport
Posted on by 23

I'm creating an App and I want a record to be inserted into SQL table once I click Submit.

So, in the submit button, Onselect I wrote a patch as below,

Patch(
    UserChangeLog;
    Defaults(UserChangeLog),
    {
        M3_User: UserID.Text,
        M3_ChangeDate: DatePickerFrom.SelectedDate,
        M3_MasterFacility:FacilityLabel.Text,
        ActualRevertTime:DatePickerFrom.SelectedDate,
        M3_ChangeFacility:FacilityDropdown.Selected.CFFACI,
        Processed:UserID.Text,
        ScheduleRevertTime:DateAdd(DatePickerFrom.SelectedDate,1,TimeUnit.Days) + Time(0,0,0,0)
    }  
)
 
Patch seems to be correct as Power App did not show any error. I revised a few time to get this.
 

Now, my SQL table name is dbo.UserChangeLog.

COLUMN_NAME                  DATA_TYPE
M3_User                              nchar
M3_MasterFacility               nchar
M3_ChangeFacility             nchar
M3_ChangeDate               datetime
Processed                          char
ScheduleRevertTime      datetime
ActualRevertTime          datetime

 

When I run my app in development mode, record is not getting inserted to the table.

I checked the permissions in SQL, I'm the DB owner. Don't know what else should I check. Please guide.

 

Thanks,

Vishwa

 

Categories:
I have the same question (0)
  • mmbr1606 Profile Picture
    14,629 Super User 2026 Season 1 on at

    hey @Vishwak 

     

    can you try this approach please:

    Patch(
     UserChangeLog;
     Defaults(UserChangeLog),
     {
     M3_User: UserID.Text,
     M3_ChangeDate: DatePickerFrom.SelectedDate,
     M3_MasterFacility: FacilityLabel.Text,
     ActualRevertTime: DatePickerFrom.SelectedDate,
     M3_ChangeFacility: FacilityDropdown.Selected.CFFACI,
     Processed: UserID.Text,
     ScheduleRevertTime: DateAdd(DatePickerFrom.SelectedDate,1,Days) + Time(0,0,0,0)
     } 
    );
    If(IsEmpty(Errors(UserChangeLog)), Notify("Record added successfully", NotificationType.Success), Notify("Failed to add record: " & Errors(UserChangeLog).Message, NotificationType.Error));
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • VK-23090237-1 Profile Picture
    23 on at

    Thank you. No, still the SQL table is not getting updated.  I tried with your patch and it gave me a success message that record got inserted successfully but when I checked in the SQL table, data is not updated. What could be the reason, any idea?

     

    Thanks,

    Vishwa

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 430

#2
timl Profile Picture

timl 318 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard