8

I have a custom list with a custom content type, with a workflow, on SharePoint 2007 as outlined in this other StackExchange question.

I'm using a Person or Group typed column to contain a list of stakeholder(s), to whom emails are addressed as To: or CC: at various stages in the workflow.

But I would also like to resolve the usernames contained within this column (or dynamic string variable), to their display names. The requirement is to include the people's names in the email salutation. At the moment I'm getting eg

Dear MYDOMAIN\BloggsJ; MYDOMAIN\DoeJ; MYDOMAIN\DoeJohn,

instead of eg

Dear Joe Bloggs, Jane Doe, John Doe,

or even better would be (if it can be done),

Dear Joe Bloggs, Jane Doe, and John Doe,


Broadly, my question is "How do I display a list of users, contained within a Person or Group column, when that column will contain more than one username?".

Specific statements/questions that may prompt a solution, based on my trains-of-thought so far are:

  1. Is there some setting I can use somewhere to adjust how these names are displayed in workflow-generated emails?

  2. Otherwise, this article describes USING VARIABLES TO RESOLVE USER NAMES... but this process operates on a single Person or Group, not a semi-colon separated list of people/groups. Is there a way to explode and/or loop over the items within the Person or Group column (from within the context of the SharePoint Designer) so that I can use this approach?

  3. I considered just using multiple Person or Group fields, each only allowing a single entry... but that seems clunky and as I'm not 100% sure at this stage if I will only ever need to cater for 2 or 3 names, may not be practical.

  4. I considered using calculated columns to break down the list of recipients, but same issue applies regarding the potential for a larger number of names. I think it comes down to requiring a mechanism to loop over the names?

  5. Are there any other 'fresh perspective' or 'outside of the box' approaches that you can think of that may help?

I appreciate your time, thanks.

** EDIT: Further information **

I'm trying to display the usernames in my Person or group field using the [%ListItemContentTypeName:PersonOrGroupFieldName%] template field within the "Define e-mail message" GUI of the SPD workflow wizard.

The output of this is always in the form DOMAINNAME\UserName regardless of what's set for the "Show field:" setting on the Person or Group's "Edit Column" page, and I've confirmed that SharePoint already has the correct display name as collected from AD (eg changing this setting to "Show field" = "Name" renders the display name, rather than the user name, when looking at the item within the SharePoint site.

So the question becomes "How do I convince the workflow to correctly resolve usernames to display names, when other aspects of SharePoint already appear to be resolving this correctly?"

6 Answers 6

4
+50

Create a Single-line of text column and make it as hidden. Through event receiver populate its value in your desired pattern (e.g. Dear Joe Bloggs, Jane Doe, and John Doe) from the "Person or Group" column. And use that new column in the workflow instead of "Person or Group" column. I know there is a overhead of writing event receiver but you will be able to achieve exactly what you want.

I hope this makes sense.

4
  • This sounds promising, thanks for your answer. I'm a competent .Net programmer but no experience programming for SP. I'll do some research into how to implement this (but in the mean time, if you do know already know of any good guides/tutorials, I'd appreciate it - but not expecting you to do my research for me).
    – Sepster
    Oct 3, 2012 at 1:18
  • The +75 spoils go to you, sir ;-) I haven't actually had a chance to implement this as won't be back in the office for a few more days - but everything I've seen so far suggests this approach is perfect. Thanks for your help!
    – Sepster
    Oct 5, 2012 at 12:59
  • You can hide columns with following steps through UI as follow: 1. Open the list and select Settings + List Settings 2. Select Advanced settings 3. Click Yes for “Allow management of content types” and then click OK. 4. From the list of content types, select the content type the column appears in, e.g. “Item”. 5. From the list of columns for the selected content type, select the column (e.g. Title). 6. Select Hidden and click OK. Oct 11, 2012 at 14:17
  • Following link will guide you through how to implement event receivers. msdn.microsoft.com/en-us/library/gg252010.aspx For updating item: DisableEventFiring(); properties.ListItem["NewColumnName"] = "Joe Bloggs"; properties.ListItem.Update(); EnableEventFiring(); Oct 11, 2012 at 14:17
1

I tackled this problem from the other direction. I created a plain text field in my List called "UserName". I then created a Name (With presence) field, called "NameUser".

Next I created a Workflow on the list to copy the plain text from "UserName" into the "NameUser" field.

When I generated a WorkFlow email from the list, the bit that says "Dear So-And-So" was extracted from the "UserName" field and the recipient's email address (and anything else needed from that person's profile) can be generated from the "NameUser" field.

So simple, you'll be kicking yourself ...

0

http://geekswithblogs.net/enriquelima/archive/2012/02/27/going-from-ldquodomainusernamerdquo-to-display-name-in-sharepoint.aspx

Check for this Link

First Change Display name Domain\User to User then only it is affected user fields in SharePoint.

5
  • Hi, thanks for your answer. Where can I find the setting to change Display Name = User?
    – Sepster
    Oct 1, 2012 at 5:37
  • That script run using Powershell. There is a 2 Chances 1)Change Single User Domian\user to User 2)Change all users at a time for particular web application Oct 1, 2012 at 6:15
  • Ah ok, I misunderstood your answer. I thought you were asking me to change a setting, and then run this script only if changing the setting didn't work. I'll have our system administrators run this command, and get back to you with your bounty if it works! ;-) Thanks again for your time, I appreciate it.
    – Sepster
    Oct 1, 2012 at 6:32
  • The display names are already in the format "Surname, Lastname", which is different to the "DOMAINNAME\LastnameFirstinitial" format that I'm experiencing... so I don't think this powershell command will help?
    – Sepster
    Oct 1, 2012 at 6:48
  • @NagarajuPattem please dont just post external links as answers! External blogs tend to be short lived and we really want to keep the good answers inside our site. Write a few lines on what you think could be the answer, and then link! Oct 2, 2012 at 8:25
0

I don't have an OOTB way to do it but this is what I used in my Silverlight Web Part to obtain that information. If you are using SPD in the column list editor you should be able to specify for the people column how you want the column returned and in your workflow or whatever you can select the value. But the way I am showing is using VS2010.

    Private Sub RequestListQuerySucceeded(ByVal sender As Object, ByVal e As ClientRequestSucceededEventArgs)
    Deployment.Current.Dispatcher.BeginInvoke(Sub()

                                                  Dim dataList As New ObservableCollection(Of RequestListModel)
                                                  Deployment.Current.Dispatcher.BeginInvoke(Sub()
                                                                                                RequestListData = New PagedCollectionView(dataList)
                                                                                                If RequestListData.CanGroup = True Then
                                                                                                    RequestListData.GroupDescriptions.Add(New PropertyGroupDescription("Status"))
                                                                                                    RequestListData.GroupDescriptions.Add(New PropertyGroupDescription("RequestDate"))
                                                                                                    RequestListData.GroupDescriptions.Add(New PropertyGroupDescription("ProductLine"))
                                                                                                End If

                                                                                            End Sub)
                                                  For Each item In NPIRequestListCollection
                                                      Dim d As New RequestListModel
                                                      d.RequestType = item("Request_x0020_Type")
                                                      d.RequestDate = item("Requested")
                                                      d.Category = item("Category")
                                                      d.Status = item("Approved")
                                                      d.CustomerName = item("Customer_x0020_Name")
                                                      d.RequestCompleted = item("Completed")
                                                      d.ProductLine = item("Product_x0020_Line")
                                                      d.EffectivityDate = item("Effectivity")
                                                      d.RequestedBy = CType(item("Requested_x0020_By"), FieldUserValue).LookupValue
                                                      d.CostImpact = item("Cost_x0020_Impact")
                                                      d.Department = item("Department")
                                                      d.Division = item("Division")
                                                      d.Description = item("Description")
                                                      d.CustomerPartNumber = item("Customer_x0020_Part_x0020_Number")
                                                      d.CustomerPhoneNumber = item("Customer_x0020_Phone_x0020_Numbe")
                                                      d.CustomerRevisionLevel = item("Customer_x0020_Revision_x0020_Le")
                                                      d.CustomerFaxNumber = item("Customer_x0020_Fax_x0020_Number")
                                                      d.CustomerContact = item("Customer_x0020_Contact")
                                                      d.EAU = item("EAU")
                                                      d.Comments = item("Comments")
                                                      Deployment.Current.Dispatcher.BeginInvoke(Sub()
                                                                                                    dataList.Add(d)
                                                                                                End Sub)

                                                  Next

                                              End Sub)
End Sub

Please note the Ctype to FieldUserValue it has properties that can display the user as you would like.

4
  • This bit sounds promising: If you are using SPD in the column list editor you should be able to specify for the people column how you want the column returned and in your workflow. Where do I find the "column list editor"? I can't find this anywhere. I'm not sure I understand the relevance of this code fragment? Can you provide some more context for this code and possibly remove the code that's not specifically relevant to my issue (I'm a competent .Net programmer, but no experience programming with SharePoint yet)?
    – Sepster
    Oct 3, 2012 at 1:00
  • THe column list editor is found by going to the List Settings for the list, clicking on the column of your person/group field and changing the drop down to something other than name. But note, this only changes the display of the item in the list view, it is still stored as domain\user and will appear as such in workflows. Oct 3, 2012 at 16:07
  • @PirateEric Ah OK yes that's already been tried, thanks (and with no luck as per my earlier "Edit: Further info" in my question and as you've suggested it's still DOMAIN\user in the workflow). I assumed the answerer was referring to something within SPD.
    – Sepster
    Oct 5, 2012 at 12:54
  • But when you pull the data from the column in the workflow it will be in the desired format. Oct 8, 2012 at 13:22
0

Select as Display Name instead of As string. enter image description here

0

easiest way is to create a column and set it as person/group and choose show name(with presence) option. Now just create a workflow to set created by field(or whoever who want to display full name) name to above created new name column

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.