{"id":498,"date":"2023-12-11T11:40:39","date_gmt":"2023-12-11T10:40:39","guid":{"rendered":"https:\/\/www.paalolav.no\/?p=498"},"modified":"2023-12-19T13:16:31","modified_gmt":"2023-12-19T12:16:31","slug":"creating-a-refiner-for-audience-targeting-in-sharepoint","status":"publish","type":"post","link":"https:\/\/www.paalolav.no\/?p=498","title":{"rendered":"Creating a refiner for Audience Targeting labels in SharePoint"},"content":{"rendered":"\n<p>When creating search experiences, the built in refiner &#8220;Audiences&#8221; returns a GUID, which is useful if you want to match the results with {User.Audience}. I.e. &#8220;(ModernAudienceAadObjectIds:{User.Audiences} OR NOT IsAudienceTargeted:true)&#8221;, which should return items audience targeted to the current user, as well as results that are not audience targeted at all.<\/p>\n\n\n\n<p>But back to the topic. In order to display the label of audience targeted items, you need to map the crawled property <em><strong>ows__ModernAudienceTargetUserField<\/strong><\/em> to a <strong>RefinableString<\/strong> and reindex the sites that use Audience Targeting. Simple as that. This could be implemented as a custom refiner in the OOTB News Search or in a custom solution like PnP Modern Search.<\/p>\n\n\n\n<p><strong>Now you can create a search experience with a refiner for Audience Targeting, which is really useful for scoping news posts in a tenant.<\/strong><\/p>\n\n\n\n<p> <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.paalolav.no\/wp-content\/uploads\/2023\/12\/Malgruppe.png\"><img loading=\"lazy\" decoding=\"async\" width=\"425\" height=\"195\" src=\"https:\/\/www.paalolav.no\/wp-content\/uploads\/2023\/12\/Malgruppe.png\" alt=\"Screen shot from PnP Modern Search that displays Audience Targeting with the label instead of a GUID.\" class=\"wp-image-499\" srcset=\"https:\/\/www.paalolav.no\/wp-content\/uploads\/2023\/12\/Malgruppe.png 425w, https:\/\/www.paalolav.no\/wp-content\/uploads\/2023\/12\/Malgruppe-300x138.png 300w\" sizes=\"(max-width: 425px) 100vw, 425px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>When creating search experiences, the built in refiner &#8220;Audiences&#8221; returns a GUID, which is useful if you want to match the results with {User.Audience}. I.e. &#8220;(ModernAudienceAadObjectIds:{User.Audiences} OR NOT IsAudienceTargeted:true)&#8221;, which should return items audience targeted to the current user, as well as results that are not audience targeted at all. But back to the topic. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":504,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[91,67,87,76],"tags":[90,88,89],"class_list":["post-498","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-audience-targeting","category-sharepoint","category-pnp-modern-search","category-search","tag-audience-targeting","tag-refiners","tag-search"],"_links":{"self":[{"href":"https:\/\/www.paalolav.no\/index.php?rest_route=\/wp\/v2\/posts\/498"}],"collection":[{"href":"https:\/\/www.paalolav.no\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.paalolav.no\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.paalolav.no\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.paalolav.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=498"}],"version-history":[{"count":2,"href":"https:\/\/www.paalolav.no\/index.php?rest_route=\/wp\/v2\/posts\/498\/revisions"}],"predecessor-version":[{"id":501,"href":"https:\/\/www.paalolav.no\/index.php?rest_route=\/wp\/v2\/posts\/498\/revisions\/501"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.paalolav.no\/index.php?rest_route=\/wp\/v2\/media\/504"}],"wp:attachment":[{"href":"https:\/\/www.paalolav.no\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.paalolav.no\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.paalolav.no\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}