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 / how to patch created d...
Power Apps
Answered

how to patch created date and modified date

(0) ShareShare
ReportReport
Posted on by 35

hi all,

 I am using excel (onedrive for business) as my data source , and I want to record each item's created time and if it has been changed, also record its modified time ;

I use the patch function when the Editform1 's  onsucess, here is my code:

 

If( EditForm1.Mode = FormMode.New, Patch(datasource,EditForm1.LastSubmit,{createdwhen: Now()}),
Patch(datesource,EditForm1.LastSubmit,{'modified when': Now()}))

 

but when i actually create a new record ,I hope the time is put in the createdwhen column, but it goes to the modified when column. I have tried several times , the results goes the same.

I think maybe the reason is because: once the editform1 has been submitted, its formmode has been changed to edit (not new) ?

I dont know and hope you guys can kindly help me, Thank you !

Categories:
I have the same question (0)
  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

    @clare-sy 

    Your theory is correct.  Once the Form is submitted its no longer in New Mode.  Put this code in the OnSuccess property of the Form instead.  If the createdwhen column is blank, its a new record.  If createdwhen is filled, then we are editing.

     

    If(
     EditForm1.LastSubmit.createdwhen=Blank(),
     Patch(datasource,EditForm1.LastSubmit,{createdwhen: Now()}),
     Patch(datesource,EditForm1.LastSubmit,{'modified when': Now()})
    )

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

     

  • clare-sy Profile Picture
    35 on at

    Your answer perfectly solves my question, thank you!

    BTW, I am wondering if the editform1 has been submitted , what is its form mode? As far as I know, there is only 3 kinds status: view/edit/new.

    Thank you!

  • clare-sy Profile Picture
    35 on at

    Your answer perfectly solves my question, thank you! BTW, I am wondering if the editform1 has been submitted , what is its form mode? As far as I know, there is only 3 kinds status: view/edit/new. Thank you!

  • mdevaney Profile Picture
    29,991 Moderator on at

    @clare-sy 
    If a form was submitted in New Mode it will be returned to Edit Mode upon successfully submitting.


    Power Apps Documentation for Form Mode

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-form

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • tasnimMo Profile Picture
    2 on at

    and if I you wanna update the modified by column how u do it ? 

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 883

#2
Valantis Profile Picture

Valantis 571

#3
11manish Profile Picture

11manish 477

Last 30 days Overall leaderboard