Archive for the ‘SharePoint 2010’ Category

Pre-populate a textbox using jQuery

Here’s the scenario:

I have a form which contains a textbox. This textbox should be populated with a query string value. Users should not be able to edit the value of the textbox while adding the item.

Solution:
The above can be achieved using a Content Editor Web Part (CEWP) and jQuery.

Steps:
1. Append the NewForm.aspx url with the following: &PageView=Shared&ToolPaneView=2
2. This will cause the ‘Add Web Part’ tool pane to show up.
3. Add a CEWP to the page.
4. Go the webparts properties and click the Source button
5. Add the following:

// Note: replace this url with the url of the jquery library residing on the site!!
<script type=”text/javascript” src=”http://intranet/InternalDocuments/jquery-1.2.6.min.js”></script>

<script>
// This method retrieves the querystring value. If the querystring is missing it returns null. I’m not the author of the method; found it on the net, can’t remember from where though 🙂
function getQuerystring(key, default_)
{
if (default_==null) default_=””;
key = key.replace(/[\[]/,”\\\[“).replace(/[\]]/,”\\\]”);
var regex = new RegExp(“[\\?&]”+key+”=([^&#]*)”);
var qs = regex.exec(window.location.href);
if(qs == null)
return ‘null’
else
return qs[1];
}

//Note: The title attribute of my textbox is called ‘Source’. Replace it with the title attribute of the textbox on your form. The query string name is all called ‘Source’, replace as appropriate.
$(document).ready(function() {
$(“input”).val(unescape(getQuerystring(‘Source’,”)));
$(“input”).attr(‘readonly’,’true’);

});
</script>

6. Hit the Save button
7. Expand ‘Appearance’ and change ‘Chrome Type’ none. This step is optional.

Reference: http://technet.microsoft.com/en-us/library/ff191228(v=office.14).aspx

Use the following procedures to reset the content index.

Warning:
The procedures will erase the content index. After a reset, search results will not be available until new crawls have been run.

Reset the content index in SharePoint Server 2010

1. Verify that the user account that is performing this procedure is a service application administrator for your FAST Search Content Search Service Application.

2. In Central Administration, in the Application Management section, click Manage service applications.

3. On the Service Applications page, in the list of service applications, click your FAST Search Content SSA.

4. On the Search Administration page, under Crawling, click Index Reset.

5. On the Search Service Application: Index Reset page, click Reset Now.

6. A confirmation dialog box appears; click OK to confirm the content index reset. The Search Service Application: Search Administration page opens and the System Status is displayed.

Before you start any new crawls, you must manually clear the content from the content collection your FAST Search Content Search Service Application was feeding to. The default collection name is sp. Note that clearing the content collection is irreversible.

To clear a FAST Search Server 2010 for SharePoint content collection, log onto the server that hosts FAST Search Server 2010 for SharePoint and follow this procedure.

Clear the content collection

1. Verify that you meet the following minimum requirements: You are a member of the FASTSearchAdministrators local group on the computer where FAST Search Server 2010 for SharePoint is installed.

2. On the Start menu, click All Programs.

3. Click Microsoft FAST Search Server 2010 for SharePoint.

4. Click the Microsoft FAST Search Server 2010 for SharePoint shell.

5. At the Microsoft FAST Search Server 2010 for SharePoint shell command prompt, type the following command:

Clear-FASTSearchContentCollection -Name <collection name>

Where:

o <collection name> is the content collection you are about to clear.

6. Wait for the command to finish. This may take some time.

SharePoint 2010: Customize out of the box Application Pages (AccessDenied, Confirmation, Error, Login, RequestAccess, Signout, WebDeleted )

In SharePoint 2010, for security reasons, master pages are not applied to the application pages AccessDenied, Confirmation, Error, Login, RequestAccess, Signout and WebDeleted, instead you’ll have to create a new custom application page and run the power shell command Set-SPCustomLayoutsPage.(source http://live.visitmix.com/MIX10/Sessions/PR02 – a must-see):

In WSS3.0 and MOSS2007 it was a real headache to customise pages such as the Access Denied page or Sign Out page without editing the out of the box SharePointRoot files.

In SPF2010 and SPS2010 this has changed with the introduction of PowerShell commands to point the location of the application page to a newly created customised one.

Get-SPCustomLayoutsPage -Identity "AccessDenied | Confirmation | Error | Login | RequestAccess | Signout | WebDeleted
Set-SPCustomLayoutsPage

“Following PS Command replaces Request Access Page (reqacc.aspx) in layouts folder, assuming customized version of Request Access page is deployed to custompages folder under layouts directory

Set-SPCustomLayoutsPage -Identity "RequestAccess" -RelativePath "/_layouts/custompages/reqacc.aspx" -WebApplication "{replace with web app url}"
(source http://www.sharepointadminwiki.com/display/sp2010/Customise+out+of+the+box+Application+Pages)

Set-SPCustomLayoutsPage: http://technet.microsoft.com/en-us/library/ff607768.aspx

Get-SPCustomLayoutsPage: http://technet.microsoft.com/en-us/library/ff607821.aspx

So, don’t change the files (error.aspx, login.aspx etc) in C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTS, but use them as templates for the new custom pages

Here is a very good overview of SharePoint developer tools to minimize development efforts and eliminate chances of error in SharePoint development.

SP2010- Developer Tools