We help IT Professionals succeed at work.

Read-only based on the value of a field

MPimentel asked
So far I've continued with my application thanks to rjcpjc who always answers back.
But here is the question to everybody:
When a client reaches certain status in my application (Application Sent, appointment, enrolled, etc), I want to turn on a field called "Locked" to "Yes" and restrict access to users to open(not view) this items. When a supervisor turns this field off, then the Items could be modified by the users. This is in a public folder. I Read about moderated folders but I don't think this is my solution, because I don't want to move the Items, I just want to make them "Read Only" based on the value of this field. Also, I don't know if permissions can be set to views specifically, I know about the roles for the folders and so on, but I want to make the custom view of a folder accesible to a certain group, the option "Make this folder visible only to me" does not make sense in this scanario. The Idea is to create a view containing this "Locked" field and if the user is a member of a group, then she could acces the view and change the value of this field, but the view in this folder would not be visible to the rest of the users.

Thank you very much
Watch Question

Well, this isn't exactly what you want, but you could put code in the Item_Write event of the actual item to check if this field was set to "Yes" and then not allow the Item_Write event to fire if that was the case.  

I THINK that if you put that in the Item_Write event it will prevent it from being edited via in cell editing.  Not 10% positive though.  I"ll test and get back.  


Sub CheckLock()
     Set oNS = Application.GetNameSpace("MAPI")
     If Item.UserProperties("Locked").Value then
          Item.Close(1) 'I tried olDiscard as well
          MsgBox "This Item Is Locked. Call Your Administrator"
     End if
     Set oNS = Nothing
End Sub

I call this procedure when the item is opened and written. It works when In-cell editing is allowed but only to contact fields (it displays my error message), not custom fields and I need all of them rolled back. I could set up the view to deny in cell editing but how would I prevent the users from changing the view?
I don't know the best way to prevent users from changing the view, but try this:

Function Item_Write

  If Item.UserProperties("Locked").Value then
     Item.Write = False
     msgbox "You cannot edit this item"
     Exit Sub
  End If

End Function

MPimentel, any update?


thanks again...

Explore More ContentExplore courses, solutions, and other research materials related to this topic.