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

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,989 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,989 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

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