Normal Topic Record changes (Read 827 times)
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Record changes
Feb 22nd, 2012 at 7:15pm
Print Post Print Post  
I would like to record which user adds a record to an existing file or when a specific element is changed in an existing record.

Is there a way to capture who is making a change to a specific element?

Is there a way to capture who creates a new record?

Thanks, in advance, for your help.

  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Record changes
Reply #1 - Feb 22nd, 2012 at 8:09pm
Print Post Print Post  
Does your application have security on it? If so you can use @UserID.

If not you can use @GetLocalEnvVar("USERNAME") to get the windows login name.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Record changes
Reply #2 - Feb 23rd, 2012 at 6:13pm
Print Post Print Post  
My application does have security so the @UserID would be OK. 

Do I just invoke the @UserID as a variable?  For example, elementx=@userID?  Can I then tie it to an On Element Change?

  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Record changes
Reply #3 - Feb 23rd, 2012 at 7:28pm
Print Post Print Post  
There are several ways you can do it.

One way to do it would be in the on Element Change event of your specific element using a bound read only element named something like RecordHistory to track changes to the record. The following is a sample of how to do that

Code
Select All
RecordHistory = @Date + ": Record Data changed by " + @UserID + @Newline() + RecordHistory 



Another way is to simply keep a Last Modified Date element and a Last Modified By element on your form. Then Program them as

Code
Select All
LastModifiedDate = @Date
LastModifiedBy = @UserID 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Record changes
Reply #4 - Feb 24th, 2012 at 1:32pm
Print Post Print Post  
Thanks, Ray

The element change programming you mention will work for me.  I'm updating the standards in the record each time it's opened.  So I can't track every change, but the RecordHistory program above will work fine.

  
Back to top
 
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Record changes
Reply #5 - Feb 24th, 2012 at 1:46pm
Print Post Print Post  
Hey, one more question.  When I use the On Element Change event, is it possible to also record what the element was before the change?
  
Back to top
 
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Record changes
Reply #6 - Feb 24th, 2012 at 6:32pm
Print Post Print Post  
Save the element value using On Element Entry.

Realistically, it would probably be better to set all this up as a function called with the value of the element and the field name, rather than coding each field in detail.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Record changes
Reply #7 - Feb 24th, 2012 at 6:54pm
Print Post Print Post  
You can also use @Attribute to get the Undo value of the element.

Code
Select All
RecordHistory = "Company changed to: " + Company + " from: " + @Attribute(Company, 39) + @Newline() + RecordHistory 



One thing to note, The undo value is the last value that is saved with the record. So if you were to change the field from "Mike's Motorcycles" to "Mike's Scootrs", press tab and then before saving the record realize the mistake and change it to "Mike's Scooters". You would have 2 entries in Record history that would look like

Quote:
Company changed to: Mike's Scooters from: Mike's Motorcycles
Company changed to: Mike's Scootrs from: Mike's Motorcycles


-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: Record changes
Reply #8 - Feb 24th, 2012 at 9:47pm
Print Post Print Post  
Thanks! That's a big help.

  
Back to top
 
IP Logged