Target Audiences in SharePoint list
-
08-02-2021 - |
質問
I have a list where I need to add Audience targeting.
I have added the site column Target Audiences
to the list.
However, when I add any SharePoint group to the audience of a list item, it shows up as ;;;;GroupName
in the list view.
Why does the ;;;;
come up in the list view? I tried it on another publishing site, and had the same behavior.
解決
This is the internal representation, the three types of values are separeted by ;;
:
AudienceIds(Guids);;DistributionListsNames;;SharePointGroups
So when you have ;;;;GroupName
it is just showing that there is nothing from the other types.
You can check more about that here: https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee906649(v%3Doffice.14)#target-a-web-part-to-a-specific-audience-programmatically
Relevant part:
You can assign three kinds of audiences to the AuthorizationFilter property. To target a Web Part to a global audience programmatically, you can retrieve the GUID for the audience you want by using a AudienceManager object and then assigning that GUID to the AuthorizationFilter property of the Web Part. You can also assign the Lightweight Directory Access Protocol (LDAP) distinguished name of a distribution list or the name value of a SharePoint group to this property.
The SharePoint Server 2010 framework requires that these three kinds of values be separated by a pair of semicolons (";;"). Multiple values for global audiences and SharePoint groups are delimited by commas, and multiple values for distribution lists are delimited by newline characters ("\n"). The following example builds a string that would be valid for assignment to the AuthorizationFilter property.
string[] audienceIDs = new string[] {"GUID", "GUID"}; string[] distributionLists = new string[] {"LDAP Distinguished Distribution List Name", "LDAP Distinguished Distribution List Name"}; string[] sharePointGroups = new string[] {"SharePoint Group Name", "SharePoint Group Name"}; string result = string.Format("{0};;{1};;{2}", string.Join(",", audienceIDs), string.Join("\n", distributionLists), string.Join(",", sharePointGroups));