cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
FelipeCaru
Level 8

Last edited by / last edit time

Hello all,

I have a -hopefully- easy to answer question: in a view form, is it possible to have a datacardValue have display the last user who edited that datacard and the time it was edited? This is if the user used the 'edit' button and then saved the info from it. For example:

Gallery -> Detail Form

- Detail form "last edit/last time edited" is null/empty space/placeholder text

-- User goes to "Edit" -> EditForm -> make changes -> save form -> back to detail form

- Detail form "last edit/last time edited" now has as value the User().Email (or name?) of the one who last made a saved change and the time it was at.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Microsoft RusselThomas
Microsoft

Re: Last edited by / last edit time

Hi @FelipeCaru ,

 

If you're using a SharePoint Online list as your data source, (and possibly CDS as well, I think), they already record this information for you in the 'Modified By' and 'Modified' columns.  All you have to do is display them on your form.

If you're using something else that doesn't already do this, then you may have to create those columns yourself and populate them with the data you want when the user submits the form.

With the columns created you can add the data cards to the form, pre-populate them with data and then hide them.

 

For the Modified By data you can create a simple plain text column in your source (let's call it ModifiedUser).  In the form, once you've refreshed the data source and added the ModifiedUser column as a datacard, the datacard Default: property should be ThisItem.ModifiedUser.  You can override this by unlocking the data card and changing it to User().Email

 

For the Modified column create a date column in your source - if you can, otherwise plain text will also work, you'll just have to convert from text to date when you want to perform date functions.  Let's assume this column is called ModifiedDate.

As before, refresh the source, add the column to the form, but this time change the Update: property to Now()

The only reason I use the Update property on the date is that if this is time sensitive and the person takes two hours to edit the form, Now() on default will record the time from when the form was initially rendered.

Update should only apply it as the form is submitted.

 

Hope this helps

RT

View solution in original post

Microsoft RusselThomas
Microsoft

Re: Last edited by / last edit time

Hi @FelipeCaru ,


What is the data type of the column "LastModifiedAt"?

What property is that formula in?  (the image is cut off on the left so I can't see which property field it is)

 

The error is saying the column "LastModifiedAt" does not have a maxlength property which would be correct if it's a date column, (as opposed to a Text column).  The fact that PowerApps is looking for a maxlength property might indicate that the type was originally text and then changed to date - but for PowerApps to recognise this you may have to refresh your data source and/or recreate/reconnect your form to the data.

 

Easiest way to test is to create a whole new form connected to the data and see if the property field is still there and giving errors.

Can you widen the screenshot to include the whole screen?

 

Kind regards,


RT

View solution in original post

6 REPLIES 6
Super User
Super User

Re: Last edited by / last edit time

If your data is saved in a SP list you will have the Modified By and Last Modified Date/Time stored on the record you edited. I currently use these to display on an audit history screen for one of my apps. 

If you are using another storage medium, you might have to create a place to store this information on each record (unless that storage medium also offers something similar to what SP does) so you can retrieve it and display on the view form.  I don't know of anything you an use independent of the data source to accomplish this goal.  

Microsoft RusselThomas
Microsoft

Re: Last edited by / last edit time

Hi @FelipeCaru ,

 

If you're using a SharePoint Online list as your data source, (and possibly CDS as well, I think), they already record this information for you in the 'Modified By' and 'Modified' columns.  All you have to do is display them on your form.

If you're using something else that doesn't already do this, then you may have to create those columns yourself and populate them with the data you want when the user submits the form.

With the columns created you can add the data cards to the form, pre-populate them with data and then hide them.

 

For the Modified By data you can create a simple plain text column in your source (let's call it ModifiedUser).  In the form, once you've refreshed the data source and added the ModifiedUser column as a datacard, the datacard Default: property should be ThisItem.ModifiedUser.  You can override this by unlocking the data card and changing it to User().Email

 

For the Modified column create a date column in your source - if you can, otherwise plain text will also work, you'll just have to convert from text to date when you want to perform date functions.  Let's assume this column is called ModifiedDate.

As before, refresh the source, add the column to the form, but this time change the Update: property to Now()

The only reason I use the Update property on the date is that if this is time sensitive and the person takes two hours to edit the form, Now() on default will record the time from when the form was initially rendered.

Update should only apply it as the form is submitted.

 

Hope this helps

RT

View solution in original post

mogulman
Level 8

Re: Last edited by / last edit time

On LastModified you need to check timezone issues.  If you are using SQL Server you need to make column type datetimeoffset.

FelipeCaru
Level 8

Re: Last edited by / last edit time

@RusselThomas 

Sorry for late answer. The last user who modified worked for me but using the Now() in Update seems to give me some problem. First time worked alright, but second time accesing edit view:

lastModAt.png

Not sure how or what to change to avoid that error

 

Microsoft RusselThomas
Microsoft

Re: Last edited by / last edit time

Hi @FelipeCaru ,


What is the data type of the column "LastModifiedAt"?

What property is that formula in?  (the image is cut off on the left so I can't see which property field it is)

 

The error is saying the column "LastModifiedAt" does not have a maxlength property which would be correct if it's a date column, (as opposed to a Text column).  The fact that PowerApps is looking for a maxlength property might indicate that the type was originally text and then changed to date - but for PowerApps to recognise this you may have to refresh your data source and/or recreate/reconnect your form to the data.

 

Easiest way to test is to create a whole new form connected to the data and see if the property field is still there and giving errors.

Can you widen the screenshot to include the whole screen?

 

Kind regards,


RT

View solution in original post

FelipeCaru
Level 8

Re: Last edited by / last edit time

@RusselThomas 

It was indeed as you said and after closing and reopening the app, along with refreshing the source, it took the field as date instead of text, so now I could use the Now() without problems.

Again, thank you very much.

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,994)