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.
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:
public class SPFieldLookupValue
{
public SPFieldLookupValue(string fieldValue)
{
if (!string.IsNullOrEmpty(fieldValue))
{
if (fieldValue == "***")
{
this.m_secretFieldValue = true;
}
else
{
// ...
}
}
}
// ...
}
Programmatically 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 an exception if we will be trying to save changes.