Monday 29 September 2014

JSRequest


In SharePoint when you are working with client side, at any point of time, you may need to get query strings.

So using JSRequest you can get that....
You can do all below things using JSRequest
1. Reading querystring values from the URL
2. Getting the file name of the page
3. Getting the path name of the file that is getting browsed.

How to write code...

Friday 26 September 2014

Custom refiners on a search results page in SharePoint 2013



If we create new Managed Property, we can't enable "refinable" as Yes – active, or Yes - latent.

So it is always better to use "empty" managed properties that are enabled as refiners by default, which come OOB.
By "empty" I mean that a crawled property is not mapped to it. This means that Site collection administrators can map a crawled property to one of these refiner-enabled managed properties.

Ref: http://blogs.technet.com/b/tothesharepoint/archive/2013/11/07/plan-to-use-refiners-on-a-search-results-page-in-sharepoint-2013.aspx

sharepoint 2013 relative path

Use below tag to get relative path in SharePoint.

Thursday 25 September 2014

Connections to the SharePoint server are currently disabled because the project is in Offline mode

Error occurred in deployment step 'Uninstall app for SharePoint': Connections to the SharePoint server are currently disabled because the project is in Offline mode. To connect to the SharePoint server, switch to Online mode by setting the project’s Server Connection property to Online, and then try the operation again.

Solution:

Open SharePoint project
Select solution
Click F4
You will see: Server Connection
Select : Online

Save

SharePoint Search box read input search key word

You can find using below code...
var keyword=ctx.CurrentItem.HitHighlightedSummary;
Steps:
Open Search result webpart Item Template(Edit Search result webpart-->Expand Display Templates
-->Under "Use a single template to display items"
Check what is the name of Item Template. Ex: SearchResult_item
Now go to Site Settings-->Master pages and page layouts -->Display Templates-->Search
Now find the Item Template which you find in the earlier steps. Ex: SearchResult_item
Download that. Open in notepad or Visual Studio
Find below code....
var keyword=ctx.CurrentItem.HitHighlightedSummary;

How to export Dataview Webpart to Excel


Add DVWP using SharePoint designer.

DVWP is binding data to MyTable. If your table name is different, please change the table name in the below script.
So that is the key to export data in to excel.

Open your page using browser.
Click Edit page.
Add content editor web part.
Now Edit content editor web part.
Click on "Source Editor.."
Copy below code and paste.


Wednesday 24 September 2014

Set Outlook email subject as required field


Open Outlook
Press Alt+F11, it will give you visual Basic editor.
Press Ctrl+R which in turn open Project-Project 1
On the Left Pane, one can see "Microsoft Outlook Objects" or "Project1", expand this. Now one can see the "ThisOutLookSession".
Double click on "ThisOutLookSession".It will open a Code pane.
Copy and Paste the following code in the right pane and save it.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim strSubject As String
strSubject = Item.Subject
If Len(Trim(strSubject)) = 0 Then
Prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject")
= vbNo Then
Cancel = True
End If
End If
End Sub

Now whenever you try to send a mail without subject, it would raise a pop-up to remind you.

The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested

I was trying to read a list column data. I have added that  column name in the caml query as ViewFields

<ViewFields><FieldRef Name='Column1' /><FieldRef Name='Column2' /></ViewFields>

I was expecting my column will come...
But i got this error..

The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested

Solution:

I have added my columns in the below way..

 objctx.load(objListData, 'Include(Column1, Column2)');

I was trying like this...
  objctx.load(objListData);

Tuesday 23 September 2014

SharePoint remove web.config entries when a feature is de-activated in WSS

CSS Positioning Example

SharePoint custom search results page

Open SharePoint Site

Create a custom search page.

Now go to site settings
Under Search -->Search Settings

Under : Which search results page should queries be sent to?

Enter your search page url.
Ok

Now your search results will come under your custom search page.

Monday 22 September 2014

The Managed Metadata Service or Connection is currently not available. The Application Pool or Managed Metadata Web Service may not have been started. Please Contact your Administrator.

Root Cause:
 Your app pool might have stopped.
Or Manage metadata service has not created in CA.

Solution: Start AppPool.
Or
Go to SharePoint Central Administration
click on Manage service applications
Click On "New"
Click on "Manage Metadata Service"
Enter all the details.

Save

Now try Managed Metadata Service 

Friday 19 September 2014

SharePoint Cross Site Publishing


Create 2 Site Collections
-Publishing
-Authoring
Open Authoring site
-Add new list
Ex: News
Add items to News list.
Now i have a list in Authoring site.
Open Publishing Site
Open any page, Edit the page.
Add webpart.
Media and Content –>Script Editor
Add web part
Edit Snippet
Here we can add Javascript code and HTML5 and REST API to get the list data.
Try to write your own code…
This is not crawled data, just we are pulling from another site collection.
If you want to show Indexed data, we have to do another way…

To activate the Cross-Site Collection Publishing feature in SPO


  1. Verify that the user account that performs this procedure is a site collection administrator on the authoring site collection.
  2. On the top-level site of the authoring site collection, on the Settings menu, click Site Settings.
  3. On the Site Settings page, in the Site Collection Administration section, click Site collection features.
  4. On the Site Collection Features page, next to Cross-Site Collection Publishing, click Activate.
Note:
Deactivating the Cross-Site Publishing feature on an authoring site will not remove the contents of a connected catalog from a publishing site. By deactivating this feature, you will no longer be able to modify existing catalog settings, or connect other publishing sites to catalogs within the site collection. To remove contents of a connected catalog from a publishing site, you have to disconnect the publishing site from the catalog.

Share a library or list as a catalog


  1. Verify that the user account that performs this procedure is a member of the Owners group on the site that contains the library or list that you want to share.
  2. Browse to the library or list that you want to share, and then do one of the following:
    • To share a library, click the LIBRARY tab, and then, on the ribbon, in the Settings group, click Library Settings.
    • To share a list, click the LIST tab, and then, on the ribbon, in the Settings group, click List Settings.
  3. On the Settings page, in the General Settings section, click Catalog Settings.
  4. On the Catalog Settings page, in the Catalog Sharing section, select the Enable this library as a catalog check box.
  5. In the Anonymous Access section, if you want don’t want anonymous users to view and search this content, click Disable anonymous access.
  6. In the Catalog Item URL Fields section, in the Available fields box, select up to five fields that uniquely identify an item in the library or list, and then click Add.After you connect a publishing site to this catalog, the fields that you specified as catalog item URL fields appear as part of the friendly URL. (See the example that follows this procedure.)
  7. In the Navigation Hierarchy section, select the column that is associated with the term set that you want to use as a navigation term set for catalog pages. After you connect a publishing site to this library or list to show catalog content, the value of the column that you selected appears as part of the friendly URL (see the example that follows this procedure).
  8. OK
Friendly URL
In Publishing Site
Click on Manage catalog connections
Click on the your  catalog.
Under: Catalog Item URL Format
Selected Fields: ListItemID
You will get URL as:
https://microsoft.sharepoint.com/teams/XXX/XXX/Term Root/Term/[ListItemID]
Create new page in Publishing site
Add new CSWP
Provide the catalog in the : Select a query
Save.
You will get the result.
Click on Any result
It will reirect to another page, based on the URL which you have given in the Manage Catalop connections
In the new page
Edit page
You can find one webpart: Catalog-Item Reuse
Edit Web part
Click on Change Query
In Select a query : You will able to see catalog name
Restrict by tag: Select: Restrict by navigation term of current page
in Add additional filters:
Remove default values.
Add below one:
ListItemID:{URLTOKEN.1}
Click Ok

SharePoint Display Templates

Display Templates:
Display Templates are used with CSWP to format/style search result generated by CSWP search query. Display Templates control which managed property is shown in the
search results and how they appear in the Web Part. Each Display Template has two files: an HTML version of the Display Template that you can edit in your HTML editor,
and a .js file that is for SharePoint use and should never be modified. CSWP uses combination of two Display Templates, Control Templates and Item Templates to render
results.
Control Template provides HTML to structure the overall layout for how you want to present the search results. For example, the Control Template might provide the HTML
for a heading, beginning and end of a list. The Control Template is rendered only once in the Web Part.
Item Template provides HTML that determines how each item in the result set is displayed. For example, the Item Display Template might provide the HTML for a list item
that contains a picture, three lines of text that are mapped to different managed properties associated with the item. The Item Display Template is rendered one time
for each item in the result set. So, if the result set contains ten items, the Item Display Template creates its section of HTML ten times.
Display Templates Location in Server:
Open SPO–>Settings–>Site Settings–>Design Manager –>Edit Display Templates
or
Open SPO–>Settings–>Site Settings–>Master pages and page layouts
Click on libraray
Open with explorer. Or Click on Display Template folder–>Content web parts
Check and html–>Download
Change this file and upload with new name. Js will create automatically.
Or
Open SPD:Open SPO–>Master Pages–>Display Templates
==>Content Web Parts
Here you can see files start with “Control_” and “Item_”.
Files starting with Control are Control Templates and files starting with Item are Item templates.
Also there are two file extensions for each file type .html and .js.
.js is strictly for SharePoint internal use and not to be changed by users.

How to turn off version for the Master Page Gallery


In our scenario, I am not using SharePoint workflows for approval. My files have already been approved, so before I upload a new master page, I want to turn off
versioning for the Master Page Gallery.
To turn off versioning for the Master Page Gallery:
1.On the LIBRARY tab, click Library Settings.
2.On the Settings page, click Versioning settings.
3.On the Versioning Settings page, in the Content Approval section, for Require content approval for submitted items, select No.
4.In the Document Version History section, for Create a version each time you edit a file in this document library, select No versioning.
5.In the Require Check Out section, for Require documents to be checked out before they can be edited, select No.
Now we’re ready to upload a new master page.

Wednesday 17 September 2014

Partitioning

Partitioning is an important feature which helps improve the performance of the queries against a very large table. The reason for this speedy retrieval of the data is that all the rows are not directly stored in the table, but are distributed in different partitions of this table. Due to the presence of the data in different subsets the query results retrieval will be faster on the server.

In this article, we will concentrate on the Range partitions, specifically horizontal range partitions. Based on the range that the value of the partitioned column falls in.

Simply saying when we partition a table we are setting a criteria of where a particular row is being stored and in which portion of the table is the row being stored. How do we set the criteria to fill the table partitions is through the Range that we define. The range is based on a particular column of the table and we call this the partition key. We set the range through Partition function and Partition Scheme.

When tables and indexes become very large, partitioning can help by partitioning the data into smaller, more manageable sections. This article focuses on horizontal partitioning, in which large groups of rows will be stored in multiple separate partitions. The definition of the partitioned set is customized, defined, and managed by your needs. Microsoft SQL Server 2008 allows you to partition your tables based on specific data usage patterns using defined ranges or lists. SQL Server 2008 also offers numerous options for the long-term management of partitioned tables and indexes by the addition of features designed around the new table and index structure.

Furthermore, if a large table exists on a system with multiple CPUs, partitioning the table can lead to better performance through parallel operations. The performance of large-scale operations across extremely large data sets (for instance many million rows) can benefit by performing multiple operations against individual subsets in parallel. example, instead of aggregating a single large table, SQL Server can work on partitions independently, and then aggregate the aggregates. In SQL Server 2008, queries joining large datasets can benefit directly from partitioning.

Below example simplifies the idea of partitioning a yearly sales table. The data is partitioned horizontally based on the month of the year making the MONTH as the partitionkey.  The range here would be January, February, March…..December.

Slowly Changing Dimensions (SCD) in Dimensional Modeling

Dimension is a term in data management and data warehousing that refers to logical groupings of data such as geographical location, customer information, or product information. Slowly Changing Dimensions (SCDs) are dimensions that have data that changes slowly, rather than changing on a time-based, regular schedule.  

In a transaction system, many a times the change is overwritten and track of change is lost.  However, a data warehouse needs to maintain all the history as the key benefit of a warehouse is to provide historical information to analyze the trend.

Below SCD Types are the most implemented methods to handle these changing dimensions in a warehouse. Let’s understand these with an example below

Example:

You have a dimensional table with customer ID ' C01' with marital status as 'single' mentioned below. Overtime, customer gets married and also moves to a new location.

Let’s see how this scenario is managed with different SCD types.

Initial Data Record:

Surrogate Key (Surrogate Key)
Customer ID (Natural Key)
Date Valid
Marital Status
Date of Birth
City
100
C01
Jan 23, 2008
Single
Jan8, 1982
Palo Alto

SCD Type1:

The Type 1 methodology overwrites old data with new data, and therefore does not track historical data at all. This is obviously done, when we are not analyzing the historical information.

Surrogate Key
Customer ID
Date Valid
Marital Status
Date of Birth
City
100
C01
July 7,2012
Married
Jan8, 1982
Francisco

The record is simple over-written and no history is maintained here.

SCD Type 2:

The Type 2 method tracks historical data by creating multiple records for a given natural key in the dimensional tables with separate surrogate keys and/or different version numbers. With Type 2, we have unlimited history preservation as a new record is inserted each time a change is made.

This is implemented using a version column or through effective date columns to know the active record.

Implemented through a Version Column

Surrogate Key
Customer ID
Date Valid
Marital Status
Date of Birth
City
Version
100
C01
Sept 23, 2004
Single
Jan8, 1982
Palo Alto
0
101
C01
Sept 23, 2004
Married
Jan8, 1982
Francisco
1

Implemented through Effective Start and End Date Columns

Surrogate Key
Customer ID
Date Valid
Marital Status
Date of Birth
City
Start-Date
End-Date
100
C01
Sept 23, 2004
Single
Jan8, 1982
Palo Alto
01-Sep-2000
23-Sep-2004
101
C01
Sept 23, 2004
Married
Jan8, 1982
Francisco
24-Sep-2004
31-12-9999

A new record is added every time there is a change in the source with the version or Effective Date columns updating accordingly.

SCD Type 3:

The Type 3 method tracks changes using separate columns. Whereas Type 2 had unlimited history preservation, Type 3 has limited history preservation, as it's limited to the number of columns designated for storing historical data and will  have only the recent historical change. Where the original table structure in Type 1 and Type 2 was very similar, Type 3 adds additional columns to the tables

Implemented through additional Original Columns

Surrogate Key
Customer ID
Date Valid
Original Marital Status
Marital Status
Date of Birth
Original City
City
100
C01
Sept 23, 2004
Single
Married
Jan8, 1982
Palo Alto
Francisco

Original Columns have been added to capture the most recent historical change.

Additional SCDs which are occasionally used:

 SCD Type 0:

·    The Type 0 method is a passive approach to managing dimension value changes, in which no action is taken.

·    Values remain as they were at the time of the dimension record was first entered.

SCD Type 4

·    The Type 4 method is usually referred to as using "history tables", where one table keeps the current data,

·    An additional table is used to keep a record of some or all changes.

SCD Type 6 / hybrid:

·     The Type 6 method combines the approaches of types 1, 2 and 3.

·     This method is also called as “Unpredictable Changes with Single-Version Overlay" in The Data Warehouse

Now that we have a good learning experience on slowly changing dimensions (SCD) and how to design tables as per the requirement to maintain history or not for the important business columns. We now move on to a new feature Introduced in SQL server 2005 and is being used extensively for large volume tables from SQL server 2005 to SQL server 2008/2012.