Help & Support
Contents
Display Legacy Contents

Search:

Home > Impact Suite > How-To Examples > Lock Records

Lock Records

You can create a script which will lock the record when it has been marked as completed. Users will not be able to update any value on the record.
When a record is completed all the controls on the form will be disabled to all users who are not a database administrator.

If you are the database administrator you can log into the record and change its 


We need to create a math formula / Script to implement this feature.

  1. In Act! go to the TOOLS menu and select IMPACT SUITE
  2. Go to the MATH tab on the left side
  3. Click on the [Create Formula] button
  4. Enter "Lock when completed" as the name ( This can be different )
  5. Select your result field ( in the screen shot below its '(none)' )
  6. Mark the STATUS as ACTIVE
  7. Change the RUN WHEN to only FORM OPEN
  8. Then copy and paste this code from below into the formula area.
  9. Click the SAVE button



NOTE - You may need to paste this code into Notepad.exe then copy from notepad into Impact

Some browsers copy formatting which can cause issues with the paste.

'----------------------------------------------
' Beginning of code 

'----------------------------------------------
If Me.HostFramework.Users.GetUser(Me.HostFramework.Contacts.GetMyRecord().ID).Role = Me.HostFramework.Roles.Role_Administrator Then
'----------------------------------------------
  ' If the current user is an 'Administrator' 
' they can edit the existing record
'----------------------------------------------
ELSE
'----------------------------------------------
' If the current user is NOT an 'Administrator' 
'----------------------------------------------
' check the 'Completed' value of the current record
If CustomSubEntity.GetFieldDescriptorByANYString("Completed",SubEntityForm.GetEntityManager).getvalue(SubEntityItem) Then 

'----------------------------------------------
' Notify the user via a message box this record cannot be edited
'----------------------------------------------
        Messagebox.Show("This record has been completed and cannot be edited.","Edit OFF", MessageBoxButtons.OK, MessageBoxIcon.Information)

'----------------------------------------------
' If Completed = TRUE then disable all the controls
'----------------------------------------------
    For Each ctr As System.Windows.Forms.Control In SubEntityForm.Controls
           ctr.enabled = false
    Next
Else 
'----------------------------------------------
' If Completed = FALSE then ENABLE all the controls
'----------------------------------------------
    For Each ctr As System.Windows.Forms.Control In SubEntityForm.Controls
           ctr.enabled = true
    Next

End If 
END IF

RETURN NOTHING
'----------------------------------------------
' End of code 

'----------------------------------------------


Properties
Article ID:
lock_records
Views: 8
Created By: jimdurkin
Modified By: [Modified By]
Created Date: 2/24/2015 3:18 PM
Last Modified: 2/24/2015 3:33 PM
Actions
Print This Article
Bookmark
Email This Article
Previous Article
Next Article