Archive

Archive for the ‘SharePoint’ Category

How to change xmx in SoapUI

November 4, 2014 Leave a comment

Recently, I have to run some integration test using SoapUI. Due to the test file size , I got the error (the memory setting is too low). To fix this , I have to change the xmx from the default 2048m to 4096m.

Update soapui xmx settings:

Make sure you back-up the file before you change the default settings and open file as administrator.

1. Update testrunner.bat for running in command line

testrunner.bat is the Soap UI batch file. It is located in C:\Program Files\SmartBear\SoapUI-Pro-5.0.0\bin (Soap UI Pro 5.0.0 default installation location) Update the Xmx setting in this file before starting the test suite (open file as Administrator).

2. Update SoapUI-Pro-5.1.2.vmoptions for running using UI

SoapUI-Pro-5.1.2.vmoptions is the Soap UI configuration file. It is located in C:\Program Files\SmartBear\SoapUI-Pro-5.0.0\bin (Soap UI Pro 5.0.0 default installation location) Update the Xmx setting in this file before starting the test suite (open file as Administrator).

References:

Java Doc

-Xmxn
Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 and Solaris 8 SPARC platforms and 2000m on Solaris 2.6 and x86 platforms, minus overhead amounts. Examples:

-Xmx83886080

-Xmx81920k

-Xmx80m

So, in simple words, you are saying Java to use Maximum of 1024 MB from available memory.

Notice there is NO SPACE between -Xmx and 1024m

Advertisements
Categories: SharePoint Tags: , , ,

How to create multiple lines Text field that can take more than 255 characters in SharePoint2010

January 14, 2013 3 comments

If you ever find the multiline textbox reach the limit of 255 characters, here is you need to do to remove the limit. You need to go to the site settings and then go to the site columns. Next, you need to go to the column setting page and change Allow unlimited length in document libraries from NO to Yes as shown below:

FROM

TO

What is new in SharePoint2013 Workflow

December 22, 2012 Leave a comment

In SharePoint 2013, Microsoft provides a new way for creating workflows while the existing SharePoint 2010 Workflow platform has been carried forward to SharePoint 2013. SharePoint 2013 workflows are powered by Windows Workflow Foundation 4, which was substantially redesigned from earlier versions. These changes bring a major advancement to workflow and make SharePoint workflows to handle much more complex scenarios.

Let’s first look at the high-level architecture of the workflow infrastructure. As you can see from the SharePoint2013 Architecture diagram below, SharePoint 2010 workflow execution was hosted in SharePoint itself, this has been retained in SharePoint 2013 to allow for backward compatibility while Windows Azure Workflow is external to SharePoint and communicates using common protocols over the Windows Azure service bus, mediated by OAuth. Windows Azure Workflow also can be installed on a separate server. This new workflow infrastructure combined with Windows Workflow Foundation 4 provides SharePoint2013 workflow with more capabilities, such as Service Bus messaging, elastic scalability, and managed service reliability.

                

SharePoint2013 Architecture

Next, let’s look at what is new in SharePoint 2013 workflow and how these changes will make it more appealing than SharePoint 2010 workflow.

1. Declarative authoring in both SharePoint Designer and Visual Studio

Workflow authoring is declarative only in SharePoint2013 Workflow. It simplified the way workflows are created and also provides a consistent experience for creating workflow in SharePoint designer and Visual Studio. Workflows are no longer compiled into managed assemblies and deployed to an assembly cache. Instead, XAML files define your workflows and frame their execution. You can see screenshot below on how you create the same workflow in Visual Studio and SharePoint Designer.

SPD Declarative workflow Authoring

Visual Studio Declarative workflow Authoring

Another great feature inside SharePoint Designer is called visual designer for workflow. This feature is enabled when you have installed Visio 2013. It provides a new way to design workflow alongside the traditional text-based workflow designer as shown below.


                

SPD Visual Designer view

2.Workflow stages to tackle more complex workflow scenarios

This is the major improvement made by Microsoft in SharePoint 2013 workflow as it allows you to create declarative state machine workflow using SharePoint. In SharePoint 2010, you can only create sequential workflow using SharePoint Designer. If you like to create state-machine workflow, you need to get a developer involved as it can only be created inside Visual Studio. Sequential workflow can only handle simple workflow as it executes in a predefined order, on the other hand, state machine workflow can model more complex workflow as it is event driven. Depending on different state, certain actions will take place.

3. New workflow actions and data type to enhance workflow capability

SharePoint 2013 adds several new SharePoint actions to extend the workflow capability. I will highlight some of the significant ones and for a complete list of the actions in SharePoint2013, you can check the MSDN.

  1. Call HTTP web service: This action enable no-code web service calls from inside a workflow. Organisation can utilize this action to have a better management of integrating external processing with workflow. As business analyst can model the actual business process inside workflow while developer can expose the external processing logic via web services.
  2. Loop: The ability to loop through a collection is missing in SharePoint2010 and having this capability will align SharePoint processing logic with what is expected from a workflow engine.
  3. Dynamic value / Dictionary type: These terms refer to the same data type, dynamic value is used in Visual Studio while dictionary type is used in SharePoint Designer. This new data type used in conjunction with HTTP web service request make it much easier to consume web services from within the workflow.
  4. Start SharePoint2010 workflow.
    There is full interoperability in SharePoint 2013 with SharePoint 2010 workflows, which is enabled by using the Workflow interop bridge.

4. Cloud ready

There is 100 percent parity in SharePoint 2013 between on-premises and Office 365 -based workflows as shown in the picture below; therefore you can easily move an on-premises workflow to the cloud. Office 365 has already got the Windows Azure Workflow installed and configured properly. You do not have to do anything if you’d like to take advantage of the new workflow capability in the Office 365.


                Office365 Architecture

As you can see, Microsoft made a big investment in SharePoint2013 workflow and these changes make the SharePoint2013 workflow more robust, easier to build and provide more capabilities to help you to streamline your business processes. We are looking forward to helping your business take advantage of these new capabilities.

References:

http://technet.microsoft.com/en-us/library/jj219638%28v=office.15%29.aspx

http://msdn.microsoft.com/en-us/library/jj163181%28v=office.15%29.aspx

http://geekswithblogs.net/KunaalKapoor/archive/2012/08/14/sharepoint-2013-ndash-workflows.aspx

http://msdn.microsoft.com/en-us/library/jj163177%28v=office.15%29.aspx

http://msdn.microsoft.com/en-us/library/jj163091%28v=office.15%29.aspx

http://msdn.microsoft.com/en-us/library/jj163181(v=office.15).aspx

http://msdn.microsoft.com/en-us/library/jj163272(v=office.15).aspx

http://www.sharepointpromag.com/article/sharepoint/sharepoint-2013-features-144003

http://weblogs.asp.net/scottgu/archive/2012/07/26/windows-azure-and-office-365.aspx

http://www.andrewconnell.com/blog/archive/2012/07.aspx

How to create SharePoint2013 workflow using visual studio

December 5, 2012 2 comments

If you like to use Visual Studio to create workflow in SharePoint2013, here are the steps on how to get started.

1. Create a SharePoint sandbox solution.

2. Add a list workflow

3. I add a WriteToHistory to the workflow.

4. Here is the final solution looks like:

5. Deploy the sandbox solution to your Office 365 Preview and activate the site collection feature first

6. Then you can activate the site features in the following orders

7. You can run your work as shown below

8. Navigate to your workflow history list, you will see the workflow is successfully completed.

You can download the solution here.

Categories: SharePoint Tags: ,

How to perform feature upgrade in SharePoint2010 part2

November 26, 2012 Leave a comment

In my last post, I showed you how to perform feature upgrade and upgrade my feature from 0.0.0.0 to 1.0.0.1. In this post, I’d like to continue on this topic and upgrade the feature again.

For the first version of my solution, I deploy a document library with a custom document set content type and then upgrade the solution so I index the application number column. Now , I will create a new version of the solution so that it will remove the threshold of the list. You can download the solution here. Once you extract your solution, the first version is in the original folder. In order to deploy the original solution, you need to run the sitecreation.ps1 in the script folder. The version 1.1 will be in the Upgrade folder and version 1.2 will be in the Upgrade2 folder.

You need to make the following changes to the existing solution.

1. Modify the ApplicationLibrary.Template.xml as highlighted below:


2. Adding the following code into the feature event receiver.

</pre>
public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters)
 {
 base.FeatureUpgrading(properties, upgradeActionName, parameters);
 SPWeb web = GetFeatureWeb(properties);
 SPList applicationLibrary = web.Lists.TryGetList(ApplicationLibraryNamesConstant.ApplicationLibraryName);

switch (upgradeActionName)
 {
 case "IndexApplicationNumber":
 if (applicationLibrary != null)
 {
 SPField queueField = applicationLibrary.Fields["ApplicationNumber"];
 queueField.Indexed = true;
 queueField.Update();
 }
 break;
 case "RemoveListThreshold":
 applicationLibrary.EnableThrottling = false;
 applicationLibrary.Update();
 break;

 }
 }
<pre>

3. Package your solution and run the feature upgrade PowerShell script.


$wspFolder ="v1.2"
$scriptPath=Split-Path $myInvocation.MyCommand.Path
$siteUrl = "http://ybbest"
$featureToCheckGuid="1b9d84cd-227d-45f1-92d4-a43008aa8fe7"
$requiredFeatureVersion="1.0.0.1"
$siteUrlOfFeatureToBeChecked="http://ybbest"
AppendLog "Starting Solution UpgradeSolutionAndFeatures.ps1" Magenta
& "$scriptPath\UpgradeSolutionAndFeatures.ps1" $siteUrl $wspFolder $featureToCheckGuid $requiredFeatureVersion $siteUrlOfFeatureToBeChecked
Write-Host

AppendLog "All features updated" "Green"

References:

Feature upgrade.

Categories: SharePoint

How to deploy the advanced search page using Module in SharePoint 2013

August 31, 2012 1 comment

Today, I’d like to show you how to deploy your custom advanced search page using module in Visual Studio 2012.Using a module is the way how SharePoint deploy all the publishing pages to the search centre. Browse to the template under 15 hive of SharePoint2013, then go to the SearchCenterFiles under Features(as shown below).Then open the Files.xml it shows how SharePoint using module to deploy advanced search.You can download the solution here.

Now I am going to show you how to deploy your custom advanced search page.The feature is located  in the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\FEATURES\SearchCenterFiles .

To deploy SharePoint advanced Search pages, you need to do the following:

1. Create SharePoint2013 project and then create a module item.

2. Find how Out of box SharePoint deploy the Advanced Search Page from Files.xml and copy and paste it into the elements.xml

<File Url="advanced.aspx" Type="GhostableInLibrary">
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/AdvancedSearchLayout.aspx, $Resources:Microsoft.Office.Server.Search,SearchCenterAdvancedSearchTitle;" />
<Property Name="Title" Value="$Resources:Microsoft.Office.Server.Search,Search_Advanced_Page_Title;" />
<Property Name="ContentType" Value="$Resources:Microsoft.Office.Server.Search,contenttype_welcomepage_name;" />
<AllUsersWebPart WebPartZoneID="MainZone" WebPartOrder="1">
<![CDATA[
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
<Assembly>Microsoft.Office.Server.Search, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.Office.Server.Search.WebControls.AdvancedSearchBox</TypeName>
<Title>$Resources:Microsoft.Office.Server.Search,AdvancedSearch_Webpart_Title;</Title>
<Description>$Resources:Microsoft.Office.Server.Search,AdvancedSearch_Webpart_Description;</Description>
<FrameType>None</FrameType>
<AllowMinimize>true</AllowMinimize>
<AllowRemove>true</AllowRemove>
<IsVisible>true</IsVisible>
<SearchResultPageURL xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">results.aspx</SearchResultPageURL>
<TextQuerySectionLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">$Resources:Microsoft.Office.Server.Search,AdvancedSearch_FindDocsWith_Title;</TextQuerySectionLabelText>
<ShowAndQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowAndQueryTextBox>
<ShowPhraseQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowPhraseQueryTextBox>
<ShowOrQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowOrQueryTextBox>
<ShowNotQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowNotQueryTextBox>
<ScopeSectionLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">$Resources:Microsoft.Office.Server.Search,AdvancedSearch_NarrowSearch_Title;</ScopeSectionLabelText>
<ShowLanguageOptions xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowLanguageOptions>
<ShowResultTypePicker xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowResultTypePicker>
<ShowPropertiesSection xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowPropertiesSection>
<PropertiesSectionLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">$Resources:Microsoft.Office.Server.Search,AdvancedSearch_AddPropRestrictions_Title;</PropertiesSectionLabelText>
</WebPart>
]]>
</AllUsersWebPart>
</File>

3. Customize your SharePoint advanced Search Page by modifying the Advanced Search Box and Export the webpart and copy the webpart file to the elements under module.

4. Export the web part and copy the content of the web part file to the elements.xml in the module.


<File Path="AdvancedSearchPage\advanced.aspx" Url="employeeAdvanced.aspx" Type="GhostableInLibrary">
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/AdvancedSearchLayout.aspx, $Resources:Microsoft.Office.Server.Search,SearchCenterAdvancedSearchTitle;" />
<Property Name="Title" Value="$Resources:Microsoft.Office.Server.Search,Search_Advanced_Page_Title;" />
<Property Name="ContentType" Value="$Resources:Microsoft.Office.Server.Search,contenttype_welcomepage_name;" />
<AllUsersWebPart WebPartZoneID="MainZone" WebPartOrder="1">
<![CDATA[
<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
<Title>Advanced Search Box</Title>
<FrameType>None</FrameType>
<Description>Displays parameterized search options based on properties and combinations of words.</Description>
<IsIncluded>true</IsIncluded>
<ZoneID>MainZone</ZoneID>
<PartOrder>1</PartOrder>
<FrameState>Normal</FrameState>
<Height />
<Width />
<AllowRemove>true</AllowRemove>
<AllowZoneChange>true</AllowZoneChange>
<AllowMinimize>true</AllowMinimize>
<AllowConnect>true</AllowConnect>
<AllowEdit>true</AllowEdit>
<AllowHide>true</AllowHide>
<IsVisible>true</IsVisible>
<DetailLink />
<HelpLink />
<HelpMode>Modeless</HelpMode>
<Dir>Default</Dir>
<PartImageSmall />
<MissingAssembly>Cannot import this Web Part.</MissingAssembly>
<PartImageLarge />
<IsIncludedFilter />
<Assembly>Microsoft.Office.Server.Search, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.Office.Server.Search.WebControls.AdvancedSearchBox</TypeName>
<SearchResultPageURL xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">results.aspx</SearchResultPageURL>
<TextQuerySectionLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">Find documents that have...</TextQuerySectionLabelText>
<ShowAndQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowAndQueryTextBox>
<AndQueryTextBoxLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
<ShowPhraseQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowPhraseQueryTextBox>
<PhraseQueryTextBoxLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
<ShowOrQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowOrQueryTextBox>
<OrQueryTextBoxLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
<ShowNotQueryTextBox xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowNotQueryTextBox>
<NotQueryTextBoxLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
<ScopeSectionLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">Narrow the search...</ScopeSectionLabelText>
<ShowScopes xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">false</ShowScopes>
<ScopeLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
<DisplayGroup xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">Advanced Search</DisplayGroup>
<ShowLanguageOptions xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">false</ShowLanguageOptions>
<LanguagesLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
<ShowResultTypePicker xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowResultTypePicker>
<ResultTypeLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox" />
<ShowPropertiesSection xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">true</ShowPropertiesSection>
<PropertiesSectionLabelText xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">Add property restrictions...</PropertiesSectionLabelText>
<Properties xmlns="urn:schemas-microsoft-com:AdvancedSearchBox">&lt;root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;  &lt;LangDefs&gt;    &lt;LangDef DisplayName="Arabic" LangID="ar"/&gt;    &lt;LangDef DisplayName="Bengali" LangID="bn"/&gt;    &lt;LangDef DisplayName="Bulgarian" LangID="bg"/&gt;    &lt;LangDef DisplayName="Catalan" LangID="ca"/&gt;    &lt;LangDef DisplayName="Simplified Chinese" LangID="zh-cn"/&gt;    &lt;LangDef DisplayName="Traditional Chinese" LangID="zh-tw"/&gt;    &lt;LangDef DisplayName="Croatian" LangID="hr"/&gt;    &lt;LangDef DisplayName="Czech" LangID="cs"/&gt;    &lt;LangDef DisplayName="Danish" LangID="da"/&gt;    &lt;LangDef DisplayName="Dutch" LangID="nl"/&gt;    &lt;LangDef DisplayName="English" LangID="en"/&gt;    &lt;LangDef DisplayName="Finnish" LangID="fi"/&gt;    &lt;LangDef DisplayName="French" LangID="fr"/&gt;    &lt;LangDef DisplayName="German" LangID="de"/&gt;    &lt;LangDef DisplayName="Greek" LangID="el"/&gt;    &lt;LangDef DisplayName="Gujarati" LangID="gu"/&gt;    &lt;LangDef DisplayName="Hebrew" LangID="he"/&gt;    &lt;LangDef DisplayName="Hindi" LangID="hi"/&gt;    &lt;LangDef DisplayName="Hungarian" LangID="hu"/&gt;    &lt;LangDef DisplayName="Icelandic" LangID="is"/&gt;    &lt;LangDef DisplayName="Indonesian" LangID="id"/&gt;    &lt;LangDef DisplayName="Italian" LangID="it"/&gt;    &lt;LangDef DisplayName="Japanese" LangID="ja"/&gt;    &lt;LangDef DisplayName="Kannada" LangID="kn"/&gt;    &lt;LangDef DisplayName="Korean" LangID="ko"/&gt;    &lt;LangDef DisplayName="Latvian" LangID="lv"/&gt;    &lt;LangDef DisplayName="Lithuanian" LangID="lt"/&gt;    &lt;LangDef DisplayName="Malay" LangID="ms"/&gt;    &lt;LangDef DisplayName="Malayalam" LangID="ml"/&gt;    &lt;LangDef DisplayName="Marathi" LangID="mr"/&gt;    &lt;LangDef DisplayName="Norwegian" LangID="no"/&gt;    &lt;LangDef DisplayName="Polish" LangID="pl"/&gt;    &lt;LangDef DisplayName="Portuguese" LangID="pt"/&gt;    &lt;LangDef DisplayName="Punjabi" LangID="pa"/&gt;    &lt;LangDef DisplayName="Romanian" LangID="ro"/&gt;    &lt;LangDef DisplayName="Russian" LangID="ru"/&gt;    &lt;LangDef DisplayName="Slovak" LangID="sk"/&gt;    &lt;LangDef DisplayName="Slovenian" LangID="sl"/&gt;    &lt;LangDef DisplayName="Spanish" LangID="es"/&gt;    &lt;LangDef DisplayName="Swedish" LangID="sv"/&gt;    &lt;LangDef DisplayName="Tamil" LangID="ta"/&gt;    &lt;LangDef DisplayName="Telugu" LangID="te"/&gt;    &lt;LangDef DisplayName="Thai" LangID="th"/&gt;    &lt;LangDef DisplayName="Turkish" LangID="tr"/&gt;    &lt;LangDef DisplayName="Ukrainian" LangID="uk"/&gt;    &lt;LangDef DisplayName="Urdu" LangID="ur"/&gt;    &lt;LangDef DisplayName="Vietnamese" LangID="vi"/&gt;  &lt;/LangDefs&gt;  &lt;Languages&gt;    &lt;Language LangRef="en"/&gt;    &lt;Language LangRef="fr"/&gt;    &lt;Language LangRef="de"/&gt;    &lt;Language LangRef="ja"/&gt;    &lt;Language LangRef="zh-cn"/&gt;    &lt;Language LangRef="es"/&gt;    &lt;Language LangRef="zh-tw"/&gt;  &lt;/Languages&gt;  &lt;PropertyDefs&gt;    &lt;PropertyDef Name="Path" DataType="url" DisplayName="URL"/&gt;    &lt;PropertyDef Name="Size" DataType="integer" DisplayName="Size (bytes)"/&gt;    &lt;PropertyDef Name="Write" DataType="datetime" DisplayName="Last Modified Date"/&gt;    &lt;PropertyDef Name="FileName" DataType="text" DisplayName="Name"/&gt;    &lt;PropertyDef Name="Description" DataType="text" DisplayName="Description"/&gt;    &lt;PropertyDef Name="Title" DataType="text" DisplayName="Title"/&gt;    &lt;PropertyDef Name="Author" DataType="text" DisplayName="Author"/&gt;    &lt;PropertyDef Name="DocSubject" DataType="text" DisplayName="Subject"/&gt;    &lt;PropertyDef Name="DocKeywords" DataType="text" DisplayName="Keywords"/&gt;    &lt;PropertyDef Name="DocComments" DataType="text" DisplayName="Comments"/&gt;    &lt;PropertyDef Name="CreatedBy" DataType="text" DisplayName="Created By"/&gt;    &lt;PropertyDef Name="ModifiedBy" DataType="text" DisplayName="Last Modified By"/&gt;    &lt;PropertyDef Name="EmployeeNumber" DataType="text" DisplayName="EmployeeNumber"/&gt;    &lt;PropertyDef Name="EmployeeId" DataType="text" DisplayName="EmployeeId"/&gt;    &lt;PropertyDef Name="EmployeeFirstName" DataType="text" DisplayName="EmployeeFirstName"/&gt;    &lt;PropertyDef Name="EmployeeLastName" DataType="text" DisplayName="EmployeeLastName"/&gt;  &lt;/PropertyDefs&gt;  &lt;ResultTypes&gt;    &lt;ResultType DisplayName="Employee Document" Name="default"&gt;      &lt;KeywordQuery/&gt;      &lt;PropertyRef Name="EmployeeNumber" /&gt;      &lt;PropertyRef Name="EmployeeId" /&gt;      &lt;PropertyRef Name="EmployeeFirstName" /&gt;      &lt;PropertyRef Name="EmployeeLastName" /&gt;    &lt;/ResultType&gt;    &lt;ResultType DisplayName="All Results"&gt;      &lt;KeywordQuery/&gt;      &lt;PropertyRef Name="Author" /&gt;      &lt;PropertyRef Name="Description" /&gt;      &lt;PropertyRef Name="FileName" /&gt;      &lt;PropertyRef Name="Size" /&gt;      &lt;PropertyRef Name="Path" /&gt;      &lt;PropertyRef Name="Write" /&gt;      &lt;PropertyRef Name="CreatedBy" /&gt;      &lt;PropertyRef Name="ModifiedBy" /&gt;    &lt;/ResultType&gt;    &lt;ResultType DisplayName="Documents" Name="documents"&gt;      &lt;KeywordQuery&gt;IsDocument="True"&lt;/KeywordQuery&gt;      &lt;PropertyRef Name="Author" /&gt;      &lt;PropertyRef Name="DocComments"/&gt;      &lt;PropertyRef Name="Description" /&gt;      &lt;PropertyRef Name="DocKeywords"/&gt;      &lt;PropertyRef Name="FileName" /&gt;      &lt;PropertyRef Name="Size" /&gt;      &lt;PropertyRef Name="DocSubject"/&gt;      &lt;PropertyRef Name="Path" /&gt;      &lt;PropertyRef Name="Write" /&gt;      &lt;PropertyRef Name="CreatedBy" /&gt;      &lt;PropertyRef Name="ModifiedBy" /&gt;      &lt;PropertyRef Name="Title"/&gt;    &lt;/ResultType&gt;    &lt;ResultType DisplayName="Word Documents" Name="worddocuments"&gt;      &lt;KeywordQuery&gt;FileExtension="doc" OR FileExtension="docx" OR FileExtension="dot" OR FileExtension="docm" OR FileExtension="odt"&lt;/KeywordQuery&gt;      &lt;PropertyRef Name="Author" /&gt;      &lt;PropertyRef Name="DocComments"/&gt;      &lt;PropertyRef Name="Description" /&gt;      &lt;PropertyRef Name="DocKeywords"/&gt;      &lt;PropertyRef Name="FileName" /&gt;      &lt;PropertyRef Name="Size" /&gt;      &lt;PropertyRef Name="DocSubject"/&gt;      &lt;PropertyRef Name="Path" /&gt;      &lt;PropertyRef Name="Write" /&gt;      &lt;PropertyRef Name="CreatedBy" /&gt;      &lt;PropertyRef Name="ModifiedBy" /&gt;      &lt;PropertyRef Name="Title"/&gt;    &lt;/ResultType&gt;    &lt;ResultType DisplayName="Excel Documents" Name="exceldocuments"&gt;      &lt;KeywordQuery&gt;FileExtension="xls" OR FileExtension="xlsx" OR FileExtension="xlsm" OR FileExtension="xlsb" OR FileExtension="ods"&lt;/KeywordQuery&gt;      &lt;PropertyRef Name="Author" /&gt;      &lt;PropertyRef Name="DocComments"/&gt;      &lt;PropertyRef Name="Description" /&gt;      &lt;PropertyRef Name="DocKeywords"/&gt;      &lt;PropertyRef Name="FileName" /&gt;      &lt;PropertyRef Name="Size" /&gt;      &lt;PropertyRef Name="DocSubject"/&gt;      &lt;PropertyRef Name="Path" /&gt;      &lt;PropertyRef Name="Write" /&gt;      &lt;PropertyRef Name="CreatedBy" /&gt;      &lt;PropertyRef Name="ModifiedBy" /&gt;      &lt;PropertyRef Name="Title"/&gt;    &lt;/ResultType&gt;    &lt;ResultType DisplayName="PowerPoint Presentations" Name="presentations"&gt;      &lt;KeywordQuery&gt;FileExtension="ppt" OR FileExtension="pptx" OR FileExtension="pptm" OR FileExtension="odp"&lt;/KeywordQuery&gt;      &lt;PropertyRef Name="Author" /&gt;      &lt;PropertyRef Name="DocComments"/&gt;      &lt;PropertyRef Name="Description" /&gt;      &lt;PropertyRef Name="DocKeywords"/&gt;      &lt;PropertyRef Name="FileName" /&gt;      &lt;PropertyRef Name="Size" /&gt;      &lt;PropertyRef Name="DocSubject"/&gt;      &lt;PropertyRef Name="Path" /&gt;      &lt;PropertyRef Name="Write" /&gt;      &lt;PropertyRef Name="CreatedBy" /&gt;      &lt;PropertyRef Name="ModifiedBy" /&gt;      &lt;PropertyRef Name="Title"/&gt;    &lt;/ResultType&gt;  &lt;/ResultTypes&gt;&lt;/root&gt;</Properties>
</WebPart>
]]>
</AllUsersWebPart>
</File>

5.Deploy your custom solution and you will have a custom advanced search page.

How to create managed properties at site collection level in SharePoint2013

August 26, 2012 1 comment

In SharePoint2013, you can create managed properties at site collection. Today, I’d like to show you how to do so through PowerShell.

1. Define your managed properties and crawled properties and managed property Type in an external csv file. PowerShell script will read this file and create the managed and the mapping.

2. As you can see I also defined variant Type, this is because you need the variant type to create the crawled property. In order to have the crawled properties, you need to do a full crawl and also make sure you have data populated for your custom column. However, if you do not want to a full crawl to create those crawled properties, you can create them yourself by using the PowerShell; however you need to make sure the crawled properties you created have the same name if created by a full crawl.

Managed properties type:
Text = 1
Integer = 2
Decimal = 3
DateTime = 4
YesNo = 5
Binary = 6

Variant Type:
Text = 31
Integer = 20
Decimal = 5
DateTime = 64
YesNo = 11

3. You can use the following script to create your managed properties at site collection level, the differences for creating managed property at site collection level is to pass in the site collection id.

param(
	[string] $siteUrl="http://SP2013/",
	[string] $searchAppName = "Search Service Application",
    $ManagedPropertiesList=(IMPORT-CSV ".\ManagedProperties.csv")
)
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$searchapp = $null

function AppendLog
{
	param ([string] $msg,
			[string] $msgColor)

	$currentDateTime = Get-Date
	$msg = $msg + " --- " + $currentDateTime

	if (!($logOnly -eq $True))
	{
		# write to console
		Write-Host -f $msgColor $msg
	}

	# write to log file
	Add-Content $logFilePath $msg
}

$scriptPath = Split-Path $myInvocation.MyCommand.Path
$logFilePath = $scriptPath + "\CreateManagedProperties_Log.txt"

function CreateRefiner
{param ([string] $crawledName, [string] $managedPropertyName, [Int32] $variantType, [Int32] $managedPropertyType,[System.GUID] $siteID)

	$cat = Get-SPEnterpriseSearchMetadataCategory –Identity SharePoint -SearchApplication $searchapp

	$crawledproperty = Get-SPEnterpriseSearchMetadataCrawledProperty -Name $crawledName -SearchApplication $searchapp -SiteCollection $siteID

	if($crawledproperty -eq $null)
	{
		Write-Host
		AppendLog "Creating Crawled Property for $managedPropertyName" Yellow
		$crawledproperty = New-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -VariantType $variantType -SiteCollection $siteID -Category $cat -PropSet "00130329-0000-0130-c000-000000131346" -Name $crawledName -IsNameEnum $false
	}

	$managedproperty = Get-SPEnterpriseSearchMetadataManagedProperty -Identity $managedPropertyName -SearchApplication $searchapp -SiteCollection $siteID  -ErrorAction SilentlyContinue

	if($managedproperty -eq $null)
	{
		Write-Host
		AppendLog "Creating Managed Property for $managedPropertyName" Yellow
		$managedproperty = New-SPEnterpriseSearchMetadataManagedProperty -Name $managedPropertyName -Type $managedPropertyType -SiteCollection $siteID -SearchApplication $searchapp -Queryable:$true -Retrievable:$true -FullTextQueriable:$true -RemoveDuplicates:$false -RespectPriority:$true -IncludeInMd5:$true
	}

	$mappedProperty = $crawledproperty.GetMappedManagedProperties() | ?{$_.Name -eq $managedProperty.Name }

	if($mappedProperty -eq $null)
	{
		Write-Host
		AppendLog "Creating Crawled -> Managed Property mapping for $managedPropertyName" Yellow
		New-SPEnterpriseSearchMetadataMapping -CrawledProperty $crawledproperty -ManagedProperty $managedproperty -SearchApplication $searchapp -SiteCollection $siteID
	}

	$mappedProperty = $crawledproperty.GetMappedManagedProperties() | ?{$_.Name -eq $managedProperty.Name }  #Get-FASTSearchMetadataCrawledPropertyMapping -ManagedProperty $managedproperty
}

$searchapp = Get-SPEnterpriseSearchServiceApplication $searchAppName
$site= Get-SPSite $siteUrl
$siteId=$site.id

Write-Host "Start creating Managed properties"
$i = 1
FOREACH ($property in $ManagedPropertiesList) {
    $propertyName=$property.managedPropertyName
    $crawledName=$property.crawledName
    $managedPropertyType=$property.managedPropertyType
    $variantType=$property.variantType
    Write-Host $managedPropertyType
    Write-Host "Processing managed property $propertyName  $($i)..."
	$i++
    CreateRefiner $crawledName $propertyName $variantType $managedPropertyType $siteId
	Write-Host "Managed property created " $propertyName
}

Key Concepts

Crawled Properties: Crawled properties are discovered by the search index service component when crawling content.

Managed Properties: Properties that are part of the Search user experience, which means they are available for search results, advanced search, and so on, are managed properties.

Mapping Crawled Properties to Managed Properties: To make a crawled property available for the Search experience—to make it available for Search queries and display it in Advanced Search and search results—you must map it to a managed property.

References

Administer search in SharePoint 2013 Preview

Managing Metadata

New-SPEnterpriseSearchMetadataCrawledProperty

New-SPEnterpriseSearchMetadataManagedProperty

Remove-SPEnterpriseSearchMetadataManagedProperty

Overview of crawled and managed properties in SharePoint 2013 Preview

Remove-SPEnterpriseSearchMetadataManagedProperty

SharePoint 2013 – Search Service Application