0

I have a question regarding the sharepoint on prem. I got a code that get the title of a sharepoint team site using CSOM, more specifically unsing the Title property and show this title in a Episerver page. The problem is that when the administrator of the team site updates the name the module still showing the old name, I understand that is because is reading the Title property that not change if the "display"-name is updated. So my question is how to get the "display"-name so this module send this name instead to Episerver? This is a SharePoint on prem containing several team sites that shows listed in the Episerver page.

Best regards Americo

2
  • Sorry, but what is EpiServer? Commented Oct 15, 2018 at 11:43
  • can you post your sample code here if no concerns. Title should get the updated Site Title property. Commented Oct 15, 2018 at 11:48

3 Answers 3

0

This is the method that get all the team sites available and extract following properties: - ID - Title - Url - Description - Members - Administrators - Type

public List<WorkRoom> GetAllAvaliableRooms(string sealedRoomAccountName, string everyoneGroupName, bool loadMembers, string rootSiteUrl)
    {
        try
        {
            List<WorkRoom> result = new List<WorkRoom>();

            SPSecurity.RunWithElevatedPrivileges(delegate ()
            {
                SPSite site = new SPSite(rootSiteUrl);
                SPWebApplication webApplication = site.WebApplication;
                SPSiteCollection siteCollections = webApplication.Sites;

                foreach (SPSite siteCollection in siteCollections)
                {
                    SPWeb rootWeb = siteCollection.RootWeb;

                    if (String.Equals(rootWeb.Url, rootSiteUrl, StringComparison.InvariantCultureIgnoreCase))
                        continue;

                    if (!String.Equals(rootWeb.WebTemplate, TEAM_SITE_TEMPLATE_NAME, StringComparison.InvariantCultureIgnoreCase))
                        continue;

                    var workRoom = new WorkRoom()
                    {
                        ID = siteCollection.ID,
                        Title = rootWeb.Title,
                        Url = siteCollection.Url,
                        Description = rootWeb.Description,
                        Members = loadMembers ? WorkRoomHelper.GetMembers(rootWeb) : new List<User>(),
                        Administrators = WorkRoomHelper.GetAdministrators(rootWeb),
                        Type = WorkRoomHelper.GetRoomType(rootWeb, sealedRoomAccountName, everyoneGroupName)
                    };

                    result.Add(workRoom);
                }
            });

            return result;
        }
        catch (Exception ex)
        {
            throw new FaultException<UnexpectedServiceFault>(new UnexpectedServiceFault()
            {
                ErrorMessage = ex.Message,
                StackTrace = ex.StackTrace,
                FriendlyErrorMessage = "There was an errpr when getting the list of available sites"
            });
        }
    }

Is this helpfull?

Regards Americo

0

You use SharePoint rest api to get the Title of the web _api/web?$select=Title

$.ajax({
 url: "http://<site url>/_api/web?$select=Title",
 type: "GET",
 headers: { "accept": "application/json;odata=verbose" },
 success: function(data){alert(data.d.Title);} ,
 error: function(data){alert('fail');}
 });
3
  • Firstly, @Americo Perez has coded in CSOM and not REST API. Secondly, the above code will get the Title of the web and not the display name. Commented Oct 15, 2018 at 16:10
  • That could work, my question is how should embed this rest anrop in the metod? and later send the display name to EpiServer? Remember that the metod is using CSOM Commented Oct 15, 2018 at 16:18
  • Can this be the answer? : Feature.DisplayName Commented Oct 15, 2018 at 17:33
0

Here is an update:

I installed SP on prem in my machineand tested the Title property. I created a team site and called it My Site. In central administration the title property is set to My Site and is the same name that the user see when open the team site. Then I change the name to My Team site by going to the Site settings -> title and description. When I checked in the central administration I noted that the Title property also got updated to My Team site.

But when I do the same test in the scarp SP on prem the title property in the central administration doesn't get updated. Its remain unchanged.

I also added a description text that doesn't show in the central administration either.

Why this is happen? is there some setting that need to be changed in the scarp SP solution?

Best regards Americo

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.