wtorek, 26 marca 2013

How to tune list view of style "Preview Pane". Part 1: duplicated "Name" field


When list's or library's view has style "Preview Pane", it shows all items' names in the list and the rest of the fields for the currently selected item is shown in the table. I don't like that the "Name" field gets duplicated in the list and in the table.

To correct this situation, run the SharePoint Designer and go to the view edition.
The inner name of the "Name" field is different for the list (LinkTitle) and for the library (LinkFilename). You can check the fields shown in the view looking for the <ViewFields> section in the code:

<ViewFields>
  <FieldRef Name="LinkFilename"/>
  <FieldRef Name="CustomField"/>
  <FieldRef Name="Modified"/>
</ViewFields>

First change the order of the fields so the "Name" field has the last position. You can do it in code or in Web GUI. 

Now find in code section that is responsible for drawing the table with fields:


<table class="ms-formtable" border="0" cellpadding="0" cellspacing="0" width="100%">
  <xsl:for-each select="ViewFields/FieldRef[not(@Explicit='TRUE')]">
    <tr>
      <td nowrap="nowrap" valign="top" width="190px"  class="ms-formlabel">
        <nobr>
          <xsl:value-of select="@DisplayName"/>
        </nobr>
      </td>
      <td valign="top" class="ms-formbody" width="400px" id="n{position()}{$WPQ}">
        <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
      </td>
    </tr>
  </xsl:for-each>
</table>

Add the xsl:if statement to eliminate the Name field from the table:

<table class="ms-formtable" border="0" cellpadding="0" cellspacing="0" width="100%">
  <xsl:for-each select="ViewFields/FieldRef[not(@Explicit='TRUE')]">
    <xsl:if test="@Name!='LinkFilename'">
      <tr>
        <td nowrap="nowrap" valign="top" width="190px"  class="ms-formlabel">
          <nobr>
            <xsl:value-of select="@DisplayName"/>
          </nobr>
        </td>
        <td valign="top" class="ms-formbody" width="400px" id="n{position()}{$WPQ}">
          <xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&amp;nbsp;</xsl:text>
        </td>
      </tr>
    </xsl:if>
  </xsl:for-each>
</table>

poniedziałek, 4 lutego 2013

Migrating WebApplication from SP2010 to SP2013

1. Take the backup of web application content database on SharePoint 2010  from sql server using Sql Server Management Studio

2. On SharePoint 2013 create new web application. Pay attention that on SharePoint 2010 your application probably has classic-mode authentication, while on SharePoint 2013 the default is claims-based authentication. To create classic-mode web application in a SharePoint 2013, execute this command in PowerShell:
New-SPWebApplication –name "<WebAppName>"
–Port <PortNumber>
–ApplicationPool "<AppPoolName>"
–ApplicationPoolAccount (Get-SPManagedAccount "<Domain>\<AccountName>")

To use an existing application pool, provide only application pool name, without account.


3. Deploy all required farm solutions to the new web application

4. Remove content database from newly created web application in Central Administration > Manage Content Databases

5. Detach or delete the content database using Sql Server Management Studio

6. Now restore the backuped database.

7. Attach the restored content database to new web application using PowerShell:

Mount-SPContentDatabase -Name <DatabaseName> -DatabaseServer <DBServerName> -WebApplication <WebAppURL>

środa, 28 listopada 2012

The ultimate way to delete SharePoint application service

i.e. Search Service Application:
stsadm.exe -o deleteconfigurationobject -id "[GUID]"

And that way you can get to know the id:
Get-SPServiceApplication |?{$_.name -eq "[ServiceApplicationName]"}


środa, 21 listopada 2012

How to rename Search Service Application databases

There are 3 databases related to Search Service Application:
  1. Administration
  2. Crawl
  3. Property
Go to Central Administration > Application Management > Manage service applications. Find on the list application of type “Search Service Application” and click on its name. Then click on the Modify button.
Now you can see these databases.
From Central Administration you can rename only the Crawl and Property databases.
For each database select Edit Properties and change the database name. “Pending update” message appears in the Pending Changes column. Then click on Apply topology changes button. Wait patiently, on my machine it took above 10 minutes to complete.
You cannot rename Administration database from Central Administration. Run Sharepoint Managemet Shell for this purpose.
Before renaming the database, you have to pause the Search Service. But first step is to get to know Search Service identity. You can read the id of your Search Service Application when you run this command:
Get-SPEnterpriseSearchServiceApplication

Pause the service:
Get-SPEnterpriseSearchServiceApplication -Identity " service_id " | Suspend-SPEnterpriseSearchServiceApplication

Rename the database:
Set-SPEnterpriseSearchServiceApplication -Identity " service_id " -DatabaseName "new_database_name" -DatabaseServer "sql_server_name"

Resume the service:
Get-SPEnterpriseSearchServiceApplication –Identity "service_id" | Resume-SPEnterpriseSearchServiceApplication

In case there were any problems with renaming the database, after suspending the service run the Sql Server Management Studio. From here you can rename the database or, what is much safer , make a copy of it. After you have rename the database "manually", run the Set-SPEnterpriseSearchServiceApplication command.

środa, 23 maja 2012

How to find out what is the site template?

First, run the Power Shell script:

$web = Get-SPWeb <Site URL>
write-host "Web Template:" $web.WebTemplate " | Web Template ID:" $web.WebTemplateId
$web.Dispose()


You now know the site template name and id. But to know the template title, as you see it when creating a new site from web interface, run this command:


Get-SPWebTemplate | Sort-Object "Name"


Here is a list of most popular site templates:


Site Definition                                                 
Site Template Name & ID
Team Site                                           
STS#0
Blank Site
STS#1
Document Workspace
STS#2
Blog
BLOG#0
Group Work Site
SGS#0
Visio Process Repository
VISPRUS#0
Basic Meeting Workspace
MPS#0
Blank Meeting Workspace
MPS#1
Decision Meeting Workspace
MPS#2
Social Meeting Workspace
MPS#3
Multipage Meeting Workspace
MPS#4
Assets Web Database
ACCSRV#1
Charitable Contributions Web Database
ACCSRV#3
Contacts Web Database               
ACCSRV#41
Issues Web Database
ACCSRV#6
Projects Web Database
ACCSRV#5
Document Center
BDR#0
Records Center
OFFILE#1
Business Intelligence Center
BICenterSite#0
My Site Host
SPSMSITEHOST#0
Personalization Site
SPSMSITE#0
Enterprise Search Center
SRCHCEN#0
Basic Search Center
SRCHCENTERLITE#0
FAST Search Center
SRCHCENTERFAST#0
Enterprise Wiki
ENTERWIKI#0
Publishing Portal
BLANKINTERNETCONTAINER#0
Publishing Site
CMSPUBLISHING#0


Export / Import site, list or document library

To export a site, list, or document library, you can use either Windows PowerShell or Central Administration. But to import them, you can use only Windows PowerShell. So let's focus on the Power Shell.

Export command:
Export-SPWeb -Identity <Site URL> [-ItemUrl <Object URL>] -Path  <Export file name> [-IncludeUserSecurity] [-IncludeVersions] [-Force <True|False>] [-NoFileCompression] [-Verbose]
Import command:
Import-SPWeb -Identity <Site URL> -Path <Export file name> [-Force] [-NoFileCompression] [-Verbose]
-Force overwrites the export package if it already exists. During import use it to overwrite the list or library that you specified.

-NoFileCompression disables file compression in the export package. The export package is stored in the folder then. Use this parameter for performance reasons. If you used this option when exporting,  you have to specify it during import  as well.

-Verbose is used it to view the progress of the operation.

The site that you are importing to must have a template that matches the template of the exported!


Here you can read how to find out what is the site template?

The site that you are importing to must have the same default language as the exported site!

wtorek, 27 marca 2012

Access denied to "Configure service accounts"

I was completely surprised to get "Access denied" message when trying to open "Configure service accounts" option in Central Administration > Security. My account was in the farm administrators group, wasn't it!

But to be in the farm administrators group was not enough. To get access to the "Configure service accounts" I had to add my account to the local Administrators group on the machine running Sharepoint server.















That's all!