Can a SharePoint list item have a target audience that is calculated or otherwise automatically determined?

I want to show target (filtered) content from a list to users. I already have a column in the list that matters Target Audience. This field is a column with several choices (input flag), which I prefer in the current input field for target audiences.

To get audience filtering for work, I, unfortunately, have to fill out the Targeted Audience field for each item in the list. My current plan is to use a simple SharePoint workflow to set the Targeted Audiences field based on my other field, but I wonder if there is a better way. Am I just looking at it wrong?

Please note that I know that the audience can also be used to hide / show web parts, but that doesn't interest me.

+4
source share
3 answers

I do not believe that target audiences can be configured as calculated fields, in which case your parameters are a workflow or event listener for a list item.

To set the value of the audience field, you can use AudienceManager.GetAudienceIDsAsText ; Gary Lapointe has a post with a usage example .

0
source

You can try and give it a whirlwind ...

 SPField audienceField = null; try { audienceField = list.Fields[Microsoft.SharePoint.Publishing.FieldId.AudienceTargeting] } catch {} if(audienceField != null) { try { Audience siteAudience; ServerContext context = ServerContext.GetContext(site); AudienceManager audManager = new AudienceManager(context); foreach (SPListItem item in list.Items) { string audienceName = item["fakeAudienceField"]; //should be the audience name created in SSP siteAudience = audManager.GetAudience(audienceName); Guid id = siteAudience.AudienceID; item["Target Audiences"] = id.ToString()+";;;;"; item.Update(); } } catch {} 
+4
source

Perhaps use a web page to display the contents of the list and use the Audiences in the web part, which makes managing the solution easier ...

0
source

All Articles