Tuesday, November 15, 2011

Changing Site Collection URL

There are no out-of-the-box command in SharePoint to rename a site collection URL, to change the URL we need to recreate the site collection with new URL and restore the previous site collection
Source site Collection URl : http://sharepointdev/sites/Mritunjay
Source site Collection URl : http://sharepointdev/sites/mritunjay

Steps to Change the site collection URL
  1. stsadm –o backup –url http://sharepointdev/sites/Mritunjay -filename backup.dat
  2. stsadm –o deletesite –url http://sharepointdev/sites/Mritunjay
  3. stsadm –o restore –url http://sharepointdev/sites/mritunjay -filename backup.dat

Tuesday, October 4, 2011

Cannot complete this action as the Secure Store Shared Service is not responding. Please contact your administrator.

While configuring the performance point 2010 I got the following issue
Cannot complete this action as the Secure Store Shared Service is not responding. Please contact your administrator.

After trying many approaches, I found the solution
1. Make sure the SecurityTokenServiceApplicationPool is running.
2. Go to System Settings -> Manage services on server
Following services should be enabled
PerformancePoint Service
Secure Store Service
Claims to Windows Token Service
3. Go to Application Management -> Manage service applications
4. Check the Secure Store is started
5. Go to App-pool and make sure the the associated App pool is running
6. Reset the IIS






Tuesday, August 2, 2011

Execute query with string

Today, I got a strange requirement to have the query as query string to execute, and tried various ways and found that the simplest way to do this is

Declare @temp Varchar(500)
Set @temp = ‘Select * From Employees’
Exec (@temp)

the above code will help us in adding or removing the clause from the query

Monday, July 25, 2011

FullTextSqlQuery Search Queries with URL

Recently I was working with Full Text SQL Search Queries and found a strange issue while filtering with the URL in the query. If the URL contains special characters its giving me the exception improper query.

My Old Query was
SELECT ArticleDate, URL FROM SCOPE()
WHERE CONTAINS(URL, 'http://mritunjay.com/sites/the site/docs/URLTest @/')

after few encoding I tried to embed the URL in the " I was able to get the correct output

SELECT ArticleDate, URLFROM SCOPE()
WHERE CONTAINS(URL, '"http://mritunjay.com/sites/the site/docs/URLTest !@$/"')

Wednesday, June 29, 2011

Windows Process Activation Service(WAS) stopped

Application pools cannot be started unless the windows Process Activation Service(WAS) is running

this error happens because of following reasons
1. Drive is out of space.
2. Folders deleted from the Inetpub : there is a great article by Scott which explains in details how to resolve. click here

Wednesday, June 22, 2011

List Throttling

List Throttling is a new feature in SharePoint 2010, it allows us to set the limit of how many rows of data can be retrieved from a list at a time. By default the list throttles to 5000 items. Let’s consider we have a list with 50000 entries and a user comes and creates a view with all the entries, then the SharePoint will return either error or the first set of results up to the number put in the list throttle.
The throttle can be set on the lookups in a list, and we can limit the lookup columns. If we have too many lookups the performance will suffer. As we limit maximum throttle for the user, we can override the same on the Object Model if we have the sufficient privilege.

using (SPSite site = new SPSite("http://mysite"))
{
using (SPWeb web = site.RootWeb)
{
try
{
SPList list = web.Lists["Shared Documents"];

SPQuery qry = new SPQuery();
qry.QueryThrottleMode = SPQueryThrottleOption.Override;

SPListItemCollection coll = list.GetItems(qry);
}
catch(SPQueryThrottledException)
{
// Throttle exception
}
}
}

Wednesday, April 6, 2011

Passing filter to View from Querystring

To pass the filter to the share point list view we can use FilterField1 and FilterValue1

FieldFilter : Column Name
FilterValue : Value of the Field

Sample
URL?FilterField1=Title&FilterValue1=Mritunjay

we can add more than one filters by just adding the FilterField2 and FilterValue3 in the querystring.

Tuesday, January 25, 2011

Adding Dropdown to Sharepoint Webpart Properties

Adding Dropdown to Sharepoint Webpart Properties

Create a Webpart and add custopm property
[WebBrowsable(false), Personalizable(PersonalizationScope.Shared)]
public string SearchPath
{
get { return _searchPath; }
set { _searchPath = value; }
}


Create a class and extend it from ToolPart

protected override void CreateChildControls()
{
webpart = this.WebPartToEdit as WebpartClass;
toolPanel = new Panel();
toolPanel.CssClass = "ms-ToolPartSpacing";
toolPanel.Controls.Add(GetToolPanel());
this.Controls.Add(toolPanel);
base.CreateChildControls();
}

public override void ApplyChanges()
{
webpart = this.WebPartToEdit as WebpartClass;
webpart.SearchPath = ddl.SelectedValue;
base.ApplyChanges();
}


Other functions in the extended class of ToolPart
private Control GetToolPanel()
{
toolPanelTable = new Table();
toolPanelTable.CellPadding = 0;
toolPanelTable.CellSpacing = 0;
toolPanelTable.Style["border-collapse"] = "collapse";
toolPanelTable.Attributes.Add("width", "100%");
toolPanelTable.Rows.Add(GetUseDropDown());
toolPanelTable.Rows.Add(GetSeperatorRow());
return toolPanelTable;
}
private TableRow GetUseDropDown()
{
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell.Controls.Add(new LiteralControl("<div ><b>DropDownName</b></div>"));
cell.Controls.Add(new LiteralControl("<div ><div <nobr>"));
ddl = RecursiveParse(); //return the Dropdown List
cell.Controls.Add(ddl);
cell.Controls.Add(new LiteralControl("</nobr></div></div>"));
row.Cells.Add(cell);
return row;
}

private TableRow GetSeperatorRow()
{
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell.Controls.Add(new LiteralControl("<div style='width:100%' ></div>"));
row.Cells.Add(cell);
return row;
}

Friday, January 21, 2011

Create a Custom View for Survey List

Work around to create Views for survey


1. Go to Settings of the Survey. And copy the List ID from URL
Example : ListID=%7BF2141E9F%2D8EA2%2D42EE%2DA965%2D52F1D7362066%7D
2. Open the View creation Page of sameSite
Example : http://SiteURL/_layouts/ViewType.aspx?List=ListID&Source=SurveyListURL
3. Then choose a view as we choose for other lists
4. Type Custom View Name.
5. Expand style tab, choose a style Basic Table
6. press OK and view is ready.

Friday, January 14, 2011

Sharepoint Search using Metadata Properties

Sharepoint Search using Metadata Properties

Creation of Metadata Property
1. Go to Shareod Services
2. Open Metadata Property mapping
3. Click on the New Managed Property
4. Fill in the details and add to Crawled Properties
5. Make sure to wait till the next crawl completes

Search Component

FullTextSqlQuery kwQuery = new FullTextSqlQuery(siteObject);
StringBuilder queryText = new StringBuilder();
queryText.Append("SELECT Title, ArticleDetails, URL "); //ArticleDetails is managed Property
queryText.Append("FROM SCOPE() WHERE ");
queryText.Append(" CONTAINS(URL , 'NEWS') AND NOT CONTAINS(URL , 'Forms') AND ");
queryText.Append(" \"scope\" = 'IntranetRelatedArticle' AND ");
queryText.Append("( FREETEXT(DEFAULTPROPERTIES, 'Mritunjay Chourasia')");
queryText.Append(" ORDER BY Rank Desc");

kwQuery.RowLimit = 5;
kwQuery.QueryText = queryText.ToString();
kwQuery.ResultTypes = ResultType.RelevantResults;
ResultTableCollection results = kwQuery.Execute();
ResultTable relevantResults = results[ResultType.RelevantResults];
while (relevantResults.Read())
{
//Search Data computation
}

Saturday, January 1, 2011

HTTP Request to get the data from the sharepoint list using jQuery.

HTTP Request to get the data from the sharepoint list using javascript/jQuery.

Create a aspx page and place under the layouts folder and name it getcommentsfromlist.aspx

Add following code on OnLoad Method
public void OnLoad()
{
SPSite site = new SPSite(Request.QueryString["URL"]); //Site URL
SPWeb web = site.OpenWeb();

SPList list = web.Lists["Comments"]; //List in which Comments will be stored
String qPageId = Request.QueryString["PageID"]; //Page ID

SPQuery query = new SPQuery();
query.Query = "" + qPageId.ToString() + "";
SPListItemCollection itemsReturnedFromQuery = list.GetItems(query);


int totalPages;

query = new SPQuery();
query.Query = "" + qPageId.ToString() + "";


foreach (SPListItem item in itemsReturnedFromQuery)
{

retData += "Author : " + item["Author"].ToString() + "Date : " + item["Created"].ToString() + "Author : " + item["Comment"].ToString()
}


RenderHtmlControls(retData);
}


protected void RenderHtmlControls(string html)
{
Response.Write(html.ToString());
Response.End();//can be removed if you want to get the other static data which sharepoint places on the page
}


We can call the above aspx page using following JQuery code to get the data

var htmlData = $.ajax({
url: "/_layouts/getcommentsfromlist.aspx?URL=" + sCommentsURL + "&PageID=" + hwPageID,
async: false
}).responseText;