Normal Topic Locking a record after a certain date (Read 1032 times)
dhopkins
Member
*
Offline



Posts: 47
Joined: Aug 20th, 2007
Locking a record after a certain date
May 1st, 2008 at 4:01pm
Print Post Print Post  
Is it possible for a user to lock a record so that no changes can be made to it?

For example. A record is entered on Monday. and on Wednsday, a supervisior would go in and lock that record so that no changes can be made. it can still be searched on, just not changed.

I didnt see anything in docks on locking records expect when Sesame does it on it's own when different users are viewing the same data. But it seems like giving that ability to a user would also be possible.

Thanks
Derrick
  
Back to top
 
IP Logged
 
renee
Lantica Support
Members
*****
Offline



Posts: 5
Joined: Oct 2nd, 2007
Re: Locking a record after a certain date
Reply #1 - May 1st, 2008 at 6:55pm
Print Post Print Post  
Yes Derrick, it is possible to lock a record after a certain date. You could use an on form entry event in combination with readonly() based on whether or not the record is set to be locked or not.

If you need more details on how to complete this task, please let us know.

-Renee
  
Back to top
 
IP Logged
 
dhopkins
Member
*
Offline



Posts: 47
Joined: Aug 20th, 2007
Re: Locking a record after a certain date
Reply #2 - May 2nd, 2008 at 3:22pm
Print Post Print Post  
Thanks.
According to the docs, readonly() affects individual elements. So I'd need to set it for each element on the form.

Could you elaborate on how I could use something like pushformattributes to take care of the entire form.

Derrick
  
Back to top
 
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: Locking a record after a certain date
Reply #3 - May 2nd, 2008 at 4:31pm
Print Post Print Post  
You can achieve this through use of @StringArrayElementList() and StringArrayAttributes. Both can be found on pages 410-411 of the 2.0 Programming Guide.

The example below will set all elements on a form to be read only after May 5th 2008.
Code
Select All
var vLockDate as Date
var vElementList as String
	vLockDate = "2008/5/5"
	vElementList = @StringArrayElementList()

	If @ServerDate() >= vLockDate Then
	{
		StringArrayAttributes(vElementList, 28, 1) //Set all elements contained in vElementList to Read Only
	}
	Else
	{
		StringArrayAttributes(vElementList, 28, 0) //Unset Read Only
	} 

  
Back to top
IP Logged
 
dhopkins
Member
*
Offline



Posts: 47
Joined: Aug 20th, 2007
Re: Locking a record after a certain date
Reply #4 - Jun 20th, 2008 at 3:10pm
Print Post Print Post  
Hi, I finally got time to implement the locking code but here's a problem that came up.

First of all (this isnt the problem part) I created a locking subroutine


[code]
subroutine lock_record()

     var vLockDate as Date
     var vElementList as String
     var vTabList as String
     vLockDate = @Date -2

     vTabList = "Orders2, order, TabPage, TabPage0, TabPage1,TabPage2, TabPage3,TabPage4, TabPage5,
TabPage6, TabPage7, TabPage8, TabPage9, TabPage10, TabPage11, TabPage12,TabPage13,TabPage14, TabPage15, TabPage16, TabPage17, TabPage18"
     vElementList = @StringArrayElementList()

     If @ServerDate() >= vLockDate Then
     {
           StringArrayAttributes(vElementList, ATTR_ID_READ_ONLY, 1) //Set all elements contained in vElementList to Read Only
     
           StringArrayAttributes(vTabList, ATTR_ID_READ_ONLY, 0) //Set all tabs to read/write
     }



end subroutine
[/code]

Now here's the problem part. It sets everything to ReadOnly. Including the tabs on the form. So it's no longer possible to click though the form to look at the information. I tried to work around it by immediatly setting the form and tabs to read/write but they are still grayed out and unclickable.

How can I make the tabs usable again while leaving the form readonly?

Thanks,
D
  
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: Locking a record after a certain date
Reply #5 - Jun 20th, 2008 at 4:30pm
Print Post Print Post  
Try

Code
Select All
vTabList = "Orders2;order;TabPage;TabPage0;TabPage1;TabPage2;TabPage3;TabPage4;TabPage5;TabPage6;TabPage7;TabPage8;TabPage9;TabPage10;TabPage11;TabPage12;TabPage13;TabPage14;TabPage15;TabPage16;TabPage17;TabPage18" 



-Ray
  

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



Posts: 47
Joined: Aug 20th, 2007
Re: Locking a record after a certain date
Reply #6 - Jun 24th, 2008 at 2:28pm
Print Post Print Post  
Ouch. Thats a goofy mistake to make.
Thanks. It works perfectly now.

D
  
Back to top
 
IP Logged