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 names

Masked user names

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
        {
            // ...
        }
    }
}
// ...
}
C#

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.

Vitaly Zhukov

Vitaly Zhukov

Tech Lead, Architect, Developer, Technical Trainer, Microsoft MVP. Over 20 years of experience in system integration and software development. I specialize in designing and implementing scalable, high-performance software solutions across various industries.

You May Also Like