0

I want to set Audience targeting on left navigation bar of SharePoint, though there are around 50 links on which i need to set the targeting on.

Every time I take a template and restore it, I manually need to update targeting again and again.
Is there a way to set audience targeting on navigation with the help of javascript/JQuery?

I am using office 365/ SharePoint online.

Thanks!

  • If you want to hide that navigation then this link might be helpful to you, blog.jussipalo.com/2012/03/sharepoint-hide-left-navigation.html – Niranjan Kulkarni Jun 19 '15 at 9:31
  • You can also enable or disable quick launch – Niranjan Kulkarni Jun 19 '15 at 9:32
  • I am not sure if you read the question right, I dont want to hide it i want to set audience targeting. As there are links I only want to display to specific groups. – iStrange Jun 19 '15 at 9:33
  • you need to add javascript iterate through user collection find the group and hide the quick launch create one js file and give its reference on the master page it will work. – Niranjan Kulkarni Jun 19 '15 at 11:24
2

This option is available if you have Publishing enabled on your site, and does not require any JavaScript.

  1. Go to Site Settings, find the Navigation link under Look and Feel. navigation link in site settings

  2. Select one of the Structural Navigation options (or if the parent is using Structural Navigation, you can select to use the same as parent).

  3. Towards the bottom will be a section called Structural Navigation: Editing and Sorting. Select the link you want to audience target, click Edit..., and a modal should pop up. Select the group(s) you want to target the link to. navigation heading edit modal

  4. Save your changes, and they should take place.

0

If Publishing Feature is not activated, we have only one option with the help of JQuery to perform audience targeting in Quick launch bar.

function TopSummaryBoxCalc()
{
    var urls = "https://tenant/sitecollection/site/_api/web/currentUser/groups?$select=title";
    var output = getListItem(urls);
}

function getListItem(urlform) 
{
    var a=[];
    $.ajax({
        url: urlform,
        method: "GET",    
        headers: {
            "Accept": "application/json; odata=verbose"
        },
        success: function (data) {
            var dataResults = data.d.results;
            for(var i = 0;i<dataResults.length;i++){
                a[i]=dataResults[i].Title.trim();

            }console.log(a);
            var answer=$.inArray( "GROUP NAME", a );

            if(answer ==-1)
            {
                $(".ms-core-listMenu-item:contains('node name1')").hide();
                $(".ms-core-listMenu-item:contains('node name2')").hide();
            }

        },
        error: function(xhr, textStatus, errorThrown) {
            alert("error:"+JSON.stringify(xhr));
        }
    });
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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