Mask "Created By" and "Modified By" user names from forms and views

A small post about an interesting SharePoint feature: mask "Created By" and "Modified By" user account names from list item forms and views.

Masked user account names

For this behavior corresponds to a boolean property SPListItem.ShowUser. Specifying a value of true, the username will be seen, "***". This applies only to fields CreatedBy and ModifiedBy.

There are IsSecretFieldValue property and one of constructors in SPFieldLookupValue class:

  1. public class SPFieldLookupValue
  2. {
  3. public SPFieldLookupValue(string fieldValue)
  4. {
  5.     if (!string.IsNullOrEmpty(fieldValue))
  6.     {
  7.         if (fieldValue == "***")
  8.         {
  9.             this.m_secretFieldValue = true;
  10.         }
  11.         else
  12.         {
  13.             // ...
  14.         }
  15.     }
  16. }
  17. // ...
  18. }

Programmaticallye we can get the LookupId property, representing user ID, but LookupValue property returns us to "***". Although this constructor is public, it is useless for us, cause SharePoint throws exception if we will be trying to save changes.


Share

Comments