Fetching the Display Name Within a Custom Workflow

If you’re working with custom workflows, and you’ve run into a scenario where you have the login name of the user in the form of domainjuser but would like to see a more user friendly display name like Joe User then here’s how you do it:

What I usually do is create an SPUser object and then use the Name property to get at the display name of the user. Once I’ve got an SPUser object created, I have access to several different properties and methods. You can view the full list on msdn. The SiteUsers property will take in a string containing the login name of the user

SPUser user = workflowProperties.web.SiteUsers[string loginName];
string fullName = user.Name;

, ,

No comments yet.

Leave a Reply