Showing posts with label sharepoint. Show all posts
Showing posts with label sharepoint. Show all posts

Wednesday, November 17, 2010

InfoPath form 2010-Add dropdown items dynamically

I was working on adding items to DropDown control in Infopath form, you can do this as explained below
Before doing this create datasource DataSources["options"]. with XML













private void BindCustomerDropDown()



{


try


{




DataTable dtCustomer = // Load datatable
if (dtCustomer != null && dtCustomer.Rows.Count > 0)


{


string name = string.Empty;


string id = string.Empty;


RemoveFirstItem();


foreach (DataRow row in dtCustomer.Rows)


{


if (row["CustomerName"] != null)


name = row["CustomerName"].ToString();






if (row["CustomerId"] != null)


id = row["CustomerId"].ToString();






AddItem(id, name);


}


RemoveFirstItem();


}


}


catch (System.Exception ex)


{


ShowMessage(ex.Message);


}






}






private void RemoveFirstItem()


{


XPathNavigator DOM = DataSources["options"].CreateNavigator();


if (DOM == null)


return;


XPathNavigator group1 = DOM.SelectSingleNode("//options", NamespaceManager);


if (group1 == null)


return;


XPathNavigator field1 = DOM.SelectSingleNode("//options/option", NamespaceManager);


if (field1 == null)


return;


field1.DeleteSelf();


group1.InnerXml = group1.InnerXml.Replace("\r", " ");


group1.InnerXml = group1.InnerXml.Replace("\n", " ");


}










private void AddItem(string itemId, string itemName)


{


//RemoveFirstItem();


XPathNavigator DOM = DataSources["options"].CreateNavigator();


if (DOM == null)


return;


XPathNavigator group1 = DOM.SelectSingleNode("//options", NamespaceManager);


if (group1 == null)


return;


XPathNavigator field1 = DOM.SelectSingleNode("//options/option", NamespaceManager);


if (field1 == null)


return;


XPathNavigator newNode = field1.Clone();


newNode.SelectSingleNode("value").SetValue(itemId);


newNode.SelectSingleNode("displayname").SetValue(itemName);


group1.AppendChild(newNode);


}
 
you can refer these links for more details
http://www.bizsupportonline.net/infopath2007/programmatically-fill-populate-drop-down-list-box-infopath-2007.htm
http://blogs.catapultsystems.com/sboldt/archive/2009/08/07/populating-a-list-box-in-infopath-2007-form-services-from-a-sql-stored-procedure.aspx

Wednesday, September 29, 2010

InfoPath 2010: Send Email on button click ( Custom Code)

I was searching for sending Mail from Infopath form, on click of button through custom code.

Initially I tried this by googling,

EmailAdapterObject myEmailAdapter =

((EmailAdapterObject)thisXDocument.DataAdapters["Email Submit Internal"]);
 myEmailAdapter.To = list@example.com;
 myEmailAdapter.Subject = "Status Report";
 myEmailAdapter.Submit();

But in above code, I was not able to get "thisXDocument" reference.

Then I used below code to send Email

Microsoft.Office.Interop.Outlook.Application objOutlook = new Microsoft.Office.Interop.Outlook.Application();



Microsoft.Office.Interop.Outlook.MailItem objOutlookMsg = (MailItem)objOutlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);





objOutlookMsg.To = "  To Address ";


//objOutlookMsg.CC = AddressCC;


//objOutlookMsg.BCC = AddressBCC;


objOutlookMsg.Subject = "TestMail";
objOutlookMsg.Body = "Body of email";

// If you want to attach image 

objOutlookMsg.Attachments.Add(@"\image\header.jpg", Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, objOutlookMsg.Body.Length + 1, "My Attachment");


objOutlookMsg.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceNormal;


//objOutlookMsg.Display(true);


objOutlookMsg.Send();


objOutlook = null;
objOutlookMsg = null;

Monday, September 6, 2010

Error while opening Infopath file

When I was trying to open Infopath file (.xsn) , I was getting below error.

This form cannot be opened because it requires the domain permission level

Error Details:
Forms that require the domain permission level contain features
that access information on a network, such as data connections, linked images, and code.
 
The solution for this is very simple.
Right click on the file, select "Design" option. this will work

Friday, May 28, 2010

Office Excel 2010 - Publish to SharePoint option not available

I was working on SharePoint 2010 Excel Services, where you can see in the Office Excel 2010, publish option to sharepoint is moved to "Save & Send" option, which comes under File, which is different from Office 2007.

But, If you go to that location,you will see Save to SharePoint option, but you will not see browse option to save that excel work sheet in to SharePoint Library.

This is because, your office installation is not uptodate. you may have to upgrade your Office Professional Plus 2010.

check this for upgrading details.
http://support.microsoft.com/kb/983473/en-us?p=1

Sunday, May 16, 2010

Data View and Data Form Web Part



Data view Webpart was the basic webpart with the “view” functionality, later the DataFormWebPart was introduced  with "view" and “form” functionality to write back to various data sources.


 Data View generically used to refer to the feature set but actually it means DataForm.
SharePoint Designer’s UI still uses the term Data View in the places of Data Form

Tuesday, April 27, 2010

Pre-Requisite for SharePoint 2010

Below are the Order of Installation for SharePoint 2010

 1  Microsoft Windows Server 2008 Standard SP2
   http://go.microsoft.com/fwlink/?LinkId=166500

 2  Microsoft .NET Framework 3.5 Service Pack 1
  http://go.microsoft.com/fwlink/?LinkId=131037


3 Windows Server 2008 with SP 2 FIX:
A hotfix that provides a method to support the token
authentication without transport security or message encryption in WCF is
available for the .NET Framework 3.5 SP1
http://go.microsoft.com/fwlink/?LinkID=160770

4 Windows PowerShell 2.0 
http://go.microsoft.com/fwlink/?LinkId=161023

5. Microsoft SQL Server 2008 SP1

http://go.microsoft.com/fwlink/?LinkId=166490

6. Cumulative update package 2 for SQL Server 2008 Service Pack 1
http://go.microsoft.com/fwlink/?LinkId=165962

7. Microsoft SQL Server 2008 Native Client

http://go.microsoft.com/fwlink/?LinkId=166505

8. Microsoft SQL Server 2008 Analysis Services ADOMD.NET
http://go.microsoft.com/fwlink/?LinkId=130651

9. ADO.NET Data Services v1.5 CTP2 for Windows Server 2008 SP2

http://go.microsoft.com/fwlink/?LinkId=158354

10 Windows Identity Framework for Windows Server 2008
http://go.microsoft.com/fwlink/?LinkID=160381

11 Microsoft Sync Framework v1.0
http://go.microsoft.com/fwlink/?LinkID=141237&clcid=0x409

12 Microsoft Filter Pack 2.0

http://go.microsoft.com/fwlink/?LinkId=166504
 
13 Microsoft Chart Controls for Microsoft .NET Framework 3.5

http://go.microsoft.com/fwlink/?LinkID=141512

14 Microsoft Server Speech Platform

http://go.microsoft.com/fwlink/?LinkID=179612

15 Speech recognition language for English
http://go.microsoft.com/fwlink/?LinkID=179613

16 Microsoft Silverlight 3
http://go.microsoft.com/fwlink/?LinkId=166506

17 SQL Server 2008 R2 November CTP Reporting Services Add-in for Microsoft SharePoint Technologies 2010

http://go.microsoft.com/fwlink/?LinkID=164654&clcid=0x409




Ref:  http://technet.microsoft.com/en-us/library/cc262485(office.14).aspx






























































SharePoint 2010 - Site Template is now saving as wsp

Observed that, the Site Template which was with the extension .stp in SharePoint 2007 is now  saving as .wsp in SharePoint 2010 and the site gallary will not be available instead templates are stored in Solution Gallaries.

"wsp" file extension was used for solution packaging in SharePoint 2007.


Go to Site Action -  Select the option "Save site as template"






 
When you save the site, you can observe that, the file has been saved with the extension .wsp


Thursday, April 15, 2010

SharePoint Key Words

What is portal




Portal is a web application that gathers information from various desperate sources to share the information among the users .


The portals has the following significant features


• collabaration


• security


• personalization


• customization


• search , etc




Site which are not portals are called vertical portal or Vortals




Windows share point services 3.0 is free licensing it has less feature compare to Moss 2007




Ghost able – stored in content database




Un ghost able – stored in hard disk



Web part




Web part is a custom control , created by a developer and deployed on to the share point site with the extension dwp or webpart(recommended) .



Web part zone




Web part zone is a logical area created by the designer on a web part page where the web part can be dropped.




Web part page




Page, which contain web parts.




There are two type of deployment


• stand alone Installation (Deployment ) – Everything is there in the same system .


• web form Installation ( Web garden) -


A Web garden is an application pool that is configured with more than one worker process. (Web gardens are to be distinguished from Web farms, which use multiple servers for a Web site.)





Hierarchy


Central administration


site administrator




Top-level sites

Top level site 1 - Top level site 2




Role




Administrator – can create sites, content, users, application, manage forms.


Designer – can create manage content and design of the website


Contributor – can only contribute to existing content .


Reader – no other permission except view.




Feature




Feature are new innovation in Moss 2007 these are plug gable component which actually modifies the structure, layout programming capability of share point site .


When you create a SharePoint site, it helps to understand where your site is in relation to the entire site hierarchy. The following three SharePoint concepts are important to know understand:


• Top-level Web site The default, top-level site provided by a Web server. To open the top-level Web site, you supply the URL of the server—for example, http://My_server — without specifying a page name or subsite. Administrators go to this site to change settings for the entire site collection.


• Subsite A complete Web site stored in a named subdirectory of the top-level Web site. Each subsite can have administration, authoring and browsing permissions that are independent from the top-level Web site and other subsites. A subsite can also have subsites of its own. Because every site below the top-level site is actually a subsite, each subsite is generally called simply a site. To open a subsite, you supply the URL of the server and any subsites—for example, http://My_server/My_site — without specifying a page name.


• Site collection A set of Web sites on a Web server, all of which have the same owner and share administration settings. Each site collection contains exactly one top-level Web site and can also contain one or more subsites. There can be multiple site collections on each Web server.


• SharePoint Online is the business collaboration platform for the Enterprise and the Web hosted by Microsoft. It provides the robust capabilities of Microsoft SharePoint Server as a cloud-based service that can help connect and empower people and reduce costs. By removing the operational burden that comes from managing the infrastructure associated with on-premises software your IT team can more rapidly respond to business needs and deliver sustainable competitive advantage for your organization.


• Application page: Allows the use of inline custom code. Application pages or "_layout" pages are stored on the SharePoint Web server and made available via a Microsoft Internet Information Services (IIS) virtual directory. Though application pages behave much like other ASPX pages and allow the use of inline custom code, they differ from content pages in that they cannot be used to host SharePoint features such as dynamic Web Parts and Web Part zones.


• Content type: A reusable collection of settings to apply to a certain category of content such as documents and folders. Content types are designed to help users organize their SharePoint content in a more meaningful way.


• Custom action: Represents a link, toolbar button, menu item, or any control that can be added to a toolbar or menu that appears in the UI. We define custom actions by using a custom action element within a feature definition file. We can bind custom actions to a list type, content type, file type, or programmatic identifier (ProgID).


• Event receiver: Evaluator of an event and definer of the behavior of an application. Windows SharePoint Services 3.0 allows us to define event handlers within libraries, lists, and sites. Event receivers can be defined by using a receiver element within a feature definition file.


• Feature: A package of Windows SharePoint Services elements that can be activated for a specific scope and that helps users accomplish a particular goal or task. Windows SharePoint Services 3.0 introduces this inherently portable and modular functionality, which simplifies modification of sites through site definitions.


• Master page: Pages that provide a consistent layout and appearance (look and feel) for SharePoint sites. They allow us to factor out layout, structure, and interface elements such as headers, footers, navigation bars, and content placeholders. Master pages in ASP.NET 2.0 and master pages in Windows SharePoint Services work in the same way.


• Module: A file or collection of file instances that define the location where the files are installed during site creation. Modules are frequently used to implement a Web Part Page in the site. We can define modules by using a module element within a feature definition file.


• SharePoint Web farm: A group of Office SharePoint 2007 servers that share the same configuration database. All site content and all configuration data is shared for all front-end Web servers in a server farm.


• Site definition: A set of files that includes a master XML configuration file that is stored on all front-end Web servers. A site definition provides the basic blueprint for how sites look, what lists they include, their default navigational structures, and so on.


• Site template: A package containing a set of differences and changes from a base site definition that is created through the UI or through implementation of the object model. The site template package is stored as a .cab-based file that can be downloaded or uploaded to site collections by users with the appropriate rights. Site templates offer a measure of portability to SharePoint applications.


• Solution: A file that is a bundling of all the components for extending Windows SharePoint Services in a particular way. A solution file has a .cab-based format with a .wsp extension. A solution is a deployable, reusable package that can contain a set of Features, site definitions, and assemblies that apply to sites, and that you can enable or disable individually. We can use the solution file to deploy the contents of a Web Part package, including assemblies, class resources, and other package components.


• Theme: A group of files (CSS, images) that allow you to define the appearance (look and feel) of Web pages. Themes in ASP.NET 2.0 and themes in SharePoint Products and Technologies work in the same way. Themes are used to help organizations to brand their portals and team sites. Office SharePoint Server 2007 includes a set of predefined themes. However, as a developer, we can create custom themes for our company.


Wednesday, April 14, 2010

Business Productivity Online Standard Suite

Got a chance to work with BPOS customization, here are some details on BPOS
Business Productivity Online Standard Suite



Microsoft Business Productivity Online Standard Suite is a set of messaging and collaboration solutions hosted by Microsoft, and consists of Exchange Online, SharePoint Online, Office Live Meeting, and Office Communications Online. These online services are designed to give your business streamlined communication with high availability, comprehensive security, and simplified IT management. Your business benefits from always up-to-date technologies that are deployed rapidly, maximizing your valuable IT resources and reducing your need for infrastructure investments.

Overview of SharePoint Online 2007


SharePoint Online Admin Center


Microsoft supports the following languages for SharePoint online: English, French, German, Japanese and Spanish. And the offering was just recently made available to a number of countries other than the United States.


Here is a quick view of what you get with SharePoint Online Standard:





SharePoint Online Standard — Key Features


SharePoint Deskless Worker


In addition to the standard user, Microsoft offers a special deskless worker subscription. This is typically a person who needs access to information on the Intranet site but does require the collaboration capabilities. Generally they may not work in the office or have an assigned PC. Deskless workers cannot upload or create documents, only view and download.


Secure and Fully Backed Up


Access to your SharePoint Online Site is encrypted with 128 bit SSL encryption. Availability is 99.9% and backups are performed every 12 hours. There is also the Recycle Bin for most content types, the exception being deleted web pages (not web part pages) and customizations done using SharePoint Designer.


You also have virus filtering of email and other content using Microsoft Forefront Security for SharePoint. There are also a number of files types that are blocked from upload to SharePoint Online including: asp, bat, exe, class and more.


Okay enough of the basics. Time to get to the heart of the situation and look at what you do and do not get with the standard version of SharePoint Online.


Getting Started


You don't create your Site Collections though the usual SharePoint Server Administration. You do through the Online Admin Center. This means you can't create a site collection from a custom template — you only have the default options available.


Remember the forty application templates that SharePoint offers free? You can upload any one of those to get a custom site created.





SharePoint Online — Create Site Collection



Once you have your first collection created you can start using SharePoint Online. You will need to add any users you want to access the site — this is also done through the Online Admin Website.


Microsoft also provides one-way Directory synchronization to help you get your users imported to SharePoint Online quickly.





SharePoint Online — Admin, Manage Users


Single Sign On Application


To make life a little easier when using SharePoint Online, you download and install the Microsoft Online Services Sign-In application. This application enables you to move through the site without having to continually provide your credentials.


SharePoint Online Standard Capabilities


SharePoint Online is offered as a collaboration and communications tool for organization's Intranets. It offers the following types of functionality.


• Collaboration
• Portals
• Search
• Content Management
• Business Process and Forms


In the standard version, you do not get all the functionality that you would if you implemented your own version of SharePoint on premise or if you subscribed to the Dedicated Version. Here's a look at what you get and don't get.


Collaboration What you get:

• Six default site templates (wiki, blog, team site, document workspace, blank, basic meeting)
• Surveys
• People and Groups
• Calendars
• Issue Tracking
• Document Collaboration
• Site Admin templates

What you don't get:


• Presence awareness
• social networking
• Templates (all meeting templates except basic)
• Site Templates (My Site, News Site, Internet Presence Site)
• Templates requiring server side code
• Server Admin Templates


Portals What you get:


• Client Integration
• SharePoint Designer Integration
• Audience Targeting to a SharePoint group
• Portal Site templates
• Site Manager
• Site and Document Aggregation
• Document Rollup Web Part
• Mobile Device Support


What you don't get:


• My Sites
• Audience targeting to distribution groups or the ability to create audiences
• Membership web parts
• User Profiles Import
• Back and Restore via SP Designer


Content Management What you get:


• Document Information and Panel Bar
• Site Authoring
• Master Pages, Page Layouts, navigation controls
• Some retention and auditing policies
• Three State Workflow and all standard document workflows
• WYSIWYG Editor
• Standard Publishing Site Templates: Collaboration and Publishing
• Site Variations


What you don't get:


• Content Staging, Publishing and Deployment
• Standard enterprise site templates
• Records repository and legal holds
• Email content as records


Search What you get:


• Search within site collection
• Security trimmed results
• Configurable scope

What you don't get:


• Cross collection search
• Enterprise content sources
• People Search
• Search Federation
• Business Data Search


Business Process and Forms What you get:


• Form Libraries
• Custom no-code workflows


What you don't get:

• Custom workflows that are coded
• Browser-based forms
• SharePoint Server OOTB workflows


Customization Capabilities


Probably one of the most important questions you may have about using SharePoint Online is what can you customize. You can do customizations, but you are limited to customizing only what doesn't require coding.


SharePoint Designer is the tool to use to customize your SharePoint Online site. With it you can:


• Create no-code workflows
• Modify and create master pages, page layouts
• Create content types and taxonomy
• Create custom site templates
• Use the Data Form Web Part to create mashups of SharePoint data or other data brought in using Web Services
• Create InfoPath Forms — no code allowed


If you are using Visual Studio to build custom web parts, features or workflows, then you don't want SharePoint Online:
• No in-line code is allowed, including code in InfoPath Forms or custom coded workflows
• Can't create features, site definitions, web parts, solutions — anything that requires something be installed and configured on the server.
• You also can't modify SharePoint files, web.config settings or security
• No custom database modifications
• No configuration changes that affect the web server or the .NET framework



SharePoint Online 2010 Overview



Microsoft is working hard to get SharePoint 2010 ready for the market. Currently Microsoft runs SharePoint 2007 with Microsoft Online Services/BPOS.
 
Reference
http://www.microsoft.com/online/business-productivity.mspx
http://www.microsoft.com/downloads/details.aspx?FamilyID=D007F35E-375C-4B11-BC40-BC9082BB224A&displaylang=en
http://www.bposrocks.com/
http://www.cmswire.com/cms/enterprise-cms/sharepoint-online-saas-review-what-it-is-and-isnt-004351.php

Monday, April 12, 2010

SharePoint 2010 : Sandboxed Solutions

Sandboxed Solutions are SharePoint Solution Package files (WSP files) that are limited in what they can do and in the server resources they can use. What they can do is limited using Process Isolation and Code Access Security limited to the SharePoint Site. The resources they can use are limited by process monitoring, logging and log aggregation. Any individual action is limited and the solution is also given a daily limit of resources. This provides for a complete isolation system that ensures code running in a sandboxed solution cannot reach out to access information beyond the scope of the deployment. Specifically, sandboxed solutions will not be able to make updates to the SharePoint object model beyond the scope of the SPSite object. Farm level and web application level changes are allowed only for read operations.


Details :
http://www.sharepointdevwiki.com/display/sp2010/SharePoint+Sandboxed+Solutions
http://blah.winsmarts.com/2009-12-SharePoint_2010_Sandboxed_Solutions__The_basics.aspx

Sunday, April 11, 2010

SharePoint 2010 Certification Exams

Microsoft has announced Certification exams for SharePoint 2010 version

SharePoint 2010 exams
For developers there are two certifications of interest

70-573: TS: Microsoft SharePoint 2010, Application Development
70-576: PRO: Designing and Developing Microsoft SharePoint 2010 Applications


Moredetails at
http://www.microsoft.com/learning/en/us/Exam.aspx?ID=70-573&locale=en-us

Share point 2010 Key Features

Share point 2010 Key Features

New User Interface including new Ribbon
The new ribbon interface is intuitive and familiar to Office users .
The SharePoint 2007 Team site looks quite a bit different from SharePoint 2010
• Master page has changed (Site Action menu now on left)
• Home Page is a wiki page


Web Edit
Sites are now like collection of WIKI pages . You can directly edit the pages and preview the changes as well before publishing the content .

Silverlight Web Part
Direct integration of silverlight webpart

Rich Theming
Along with Wide range of theme selection already available under default site themes the users are also given a choice to import a theme from Power point and apply them to the sites and site collections .

Multiple Browser Support
Supports all XHTML 1.0 compliant browsers, IE 7 , 8.0 , Firefox , Safari , Opera & Apple Safari

Visio Services
This allows the users to share & collaborate on VISIO diagrams . A built in VISIO Viewer will allow the user to view Visio files without the need to install VISIO in their systems

SharePoint Designer
· SPD shell’s focus on SharePoint objects
1. SPD objects have relationships
2. Intuitive navigation between SPD objects

· SPD work migrates to Visual Studio 2010
SPD customization work exported to .wsp files and these wsp files can be imported into Visual Studio

SharePoint Workspace
Allows connectivity to share point even offline and thereby do useful work
Business Connectivity Services(the evolution of the Business Data Catalog)
Improvement over the previously available BDC services since it doesn’t require any code to connect to external data sources .

Media Player Web part
Built on Silverlight which can play videos from share point or remote locations

· Back up and restore

Stsadm need not be used but it is provided for backward compatibility . Windows power shell can instead be used for the same which enables back up and restore for entire farm or site collections or subsites , or even lists and also from unattached content databases .

Office Web Application Services
Can read and write any format that desktop Word can read and write . Users can view Office Client documents and work with them without Office Client being installed in their machines.
New client-side object model and runtime
New Share point API that runs on Client and can be called from Javascript or .NET or Silverlight
Power Shell Support
Allows user to write powerful Scripts against the WSS OM


LINQ support
A query language that can work across a wide variety of sources (SQL, XML, Files, SharePoint Lists)
Visual Studio 2010 Tools
Package Designer and Web Part Editor
Enhanced Collaboration Features
Allows Tagging of content
Enhanced Blog Authoring capabilities
Rich text editor to create WIKI’s

Enterprise Content Management (ECM)

1. Managed Metadata
- If you wish to give a synonym to tagged items which will show up as suggestions during search.
2. Syndicated Content Types
- Scope of content types created isnt limited to Sites as in 2007 . Here its applicable in multiple Site collections & also across the farms .
3. Unique Document ID generation for every Document
4. Document Set Concept
New object similar to Folder in 2007 , to manage work products made up of multiple documents and manage workflows .
5. Advanced Routing

Managed Term Sets
1. Predefined set of hierarchical terms
2. Defined by administrators
3. Bind to field in list, library or content type
4. ‟Like a super choice field”
5. Most recently used
6. Sets can be imported



Improved Workflows
New workflow designer surface available in SPD , which can be imported to visual studio 2010 and SPD actions can be set up and used in Visual studio

Limitations with SP2010

SharePoint 2010 will only be available in a 64-bit version. This change is not limited to servers. Developers running on 32-bit hardware will need new machines.
SharePoint 2010 will require a 64-bit version of SQL Server 2005 or 2008 (2000 is no longer supported).
Not all applications written for SharePoint 2007 will work in 2010. Certain APIs will be no longer be available. Others will be deprecated.
The basic flow for many tasks as changed. That, coupled with the laundry list of productivity-enhancing features means that any 2010 deployment should be accompanied by training for users, administrators, and developers.

Ref http://sharepoint2010.microsoft.com/product/capabilities/Sites/Pages/default.aspx



Thursday, April 8, 2010

SharePoint 2010 workflow actions error

If you get below error,
"The list of workflow actions on the server references an assembly that does not exist. Some actions will not be available. the assembly strong name is Microsoft.sharepoint.workflowactions"

Make sure the assembly which you are reffering in action xml is available in GAC

Wednesday, December 3, 2008

SharePoint Picture Library

As a Task, I was suppose to Create Picture Library, where user can browse through the Image gallery

Add an entry under List Instance

Add an Entry in List Template

OnQuickLaunch="FALSE" SecurityBits="11" Sequence="9032" DisplayName="Test Picture Library metadata" Description="Defines the list that will contain the Test Picture Library metadata." FeatureId="1F8BC8B5-63BB-2223-3D13-C2F6E980C634" RootWebOnly="TRUE" NoCrawl="TRUE" DocumentTemplate="100" Image="/_layouts/images/itil.gif"/>

Make sure that you give the Type as 109 – which is for Picture Library

To Create Schema, If you have installed SharePoint extension, Create a project and Create Picture Library List which will give you Schema.xml

Or go to

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\PictureLibrary\PicLib

Copy past the Schema.xml from this path

Create a Feature with the Entry

Create Manifest and WSP file with usual procedure

Note: Ensure that the folder name which you have specified in ListTemplate is same as the folder name where your Schema.xml file is kept.

Thursday, March 6, 2008

Sharepoint Custom Search

Sharepoint Custom Search

Points we need to make sure before using Search Option

Open the project "SharePoint.Search".
Go to the method "ExecuteFullTextSqlQuery" In SearchResults.ascx.cs page, where we can see query which retrieves data

"SELECT FileExtension, Rank, ContentClass, Path, Title, Abstract, IsDocument FROM SCOPE()"

Go to Central Administration,

Shared Services Administration: SharedServices1 > Search Settings > Managed Properties

Open Metadata Property Mappings page

Check All the fields which is specified in the query exist or not .

If the fields doesn't exist, go to New Managed Property at the top and add the field.

Check the checkbox "Use in Scope"

Common errors which may occur are :

Property doesn't exist or is used in a manner inconsistent with schema settings.
Possible reason : Field doesn't exist in Metadata Property Mappings

Your query is malformed. Please rephrase your query
Possible reason : Query is nor formatted properly

After doing this, again if the data is not coming, Comment the line
//sbFullTextSqlQuery.Append(" \"Scope\" = '" + _scope + "' ");

Because this may give error as "Scope in your query does not exist"

To know more about how this works, check this links

http://msdn2.microsoft.com/en-us/library/bb608305.aspx
http://www.ureader.com/msg/12294188.aspx




The code below says about how we can customize sharepoint search option


protected void btnSearch_Click(object sender, EventArgs e)
{
ResultTableCollection resultTableCollection = FetchRelevantSearchResults();
ResultTable relevantResultsResultTable = resultTableCollection[ResultType.RelevantResults];

DataTable relevantResultsDataTable = new DataTable();
relevantResultsDataTable.Load(relevantResultsResultTable, LoadOption.OverwriteChanges);

if (relevantResultsDataTable != null)
{
grdSearch.DataSource = relevantResultsDataTable;
grdSearch.DataBind();
}

}
// Fetch search result
private ResultTableCollection FetchRelevantSearchResults()
{
ResultTableCollection resultTableCollection = null;

SPSecurity.RunWithElevatedPrivileges(delegate()
{
try
{
ExecuteFullTextSqlQuery(out resultTableCollection);
}
catch (Exception ex)
{

}
});

return resultTableCollection;
}

// Call CAML query
private void ExecuteFullTextSqlQuery(out ResultTableCollection resultTableCollection)
{
// Guid _currentSiteGuid = SPContext.Current.Site.ID;



//using (SPSite _SPSite = new SPSite(_currentSiteGuid))
//http://mossdev:6076
//http://mossdev:35643/
using (SPSite _SPSite = new SPSite("http://mossdev:35643"))
{
using (FullTextSqlQuery _FullTextSqlQuery = new FullTextSqlQuery(_SPSite))
{
_FullTextSqlQuery.StartRow = 0;
_FullTextSqlQuery.RowLimit = 2;
_FullTextSqlQuery.HighlightedSentenceCount = 3;
_FullTextSqlQuery.EnableStemming = true;
_FullTextSqlQuery.TrimDuplicates = true;
_FullTextSqlQuery.Culture = CultureInfo.CurrentCulture;
_FullTextSqlQuery.KeywordInclusion = KeywordInclusion.AnyKeyword;
if (SPSecurity.AuthenticationMode != AuthenticationMode.Windows)
{
_FullTextSqlQuery.AuthenticationType = QueryAuthenticationType.PluggableAuthenticatedQuery;
}
else
{
_FullTextSqlQuery.AuthenticationType = QueryAuthenticationType.NtAuthenticatedQuery;
}
_FullTextSqlQuery.ResultTypes = ResultType.RelevantResults;

StringBuilder sbFullTextSqlQuery = new StringBuilder(string.Empty);
sbFullTextSqlQuery.Append("SELECT ");
sbFullTextSqlQuery.Append(" FileExtension, Rank, ContentClass, Path, Title, Abstract, IsDocument ");
sbFullTextSqlQuery.Append("FROM ");
sbFullTextSqlQuery.Append(" SCOPE() ");
sbFullTextSqlQuery.Append("WHERE ");
sbFullTextSqlQuery.Append(" FREETEXT(defaultproperties, 'raj') ");
sbFullTextSqlQuery.Append("AND ");
sbFullTextSqlQuery.Append(" \"Scope\" = 'Knowledge Objects' ");
sbFullTextSqlQuery.Append("AND ");
sbFullTextSqlQuery.Append(" ( ");
sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_DocumentLibrary') ");
sbFullTextSqlQuery.Append(" OR ");
sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_850') ");
sbFullTextSqlQuery.Append(" OR ");
sbFullTextSqlQuery.Append(" (ContentClass = 'STS_Web') ");
sbFullTextSqlQuery.Append(" ) ");
sbFullTextSqlQuery.Append("ORDER BY ");
sbFullTextSqlQuery.Append(" Rank DESC ");
// sbFullTextSqlQuery = new StringBuilder();
//sbFullTextSqlQuery.Append("SELECT Title, Abstract, Rank FROM scope() WHERE scope='All Sites' ");

//sbFullTextSqlQuery.Append("SELECT Account,CreatedBy FROM scope() ");

// fields needs mapping Title,Abstract,

// sbFullTextSqlQuery.Append("SELECT FileExtension, Rank, contentclass, Path,IsDocument FROM SCOPE() WHERE FREETEXT(defaultproperties, 'company') AND Scope = 'Knowledge Objects' AND ( (IsDocument = 1 AND ContentClass = 'STS_ListItem_DocumentLibrary') OR (IsDocument = 1 AND ContentClass = 'STS_ListItem_850') OR (ContentClass = 'STS_Web') ) ORDER BY Rank DESC") ;

//sbFullTextSqlQuery.Append("SELECT FileExtension,contentclass,Rank,Path,IsDocument FROM SCOPE() WHERE FREETEXT(defaultproperties, 'company')");
//sbFullTextSqlQuery.Append("AND ");
//sbFullTextSqlQuery.Append(" ( ");
//sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_DocumentLibrary') ");
//sbFullTextSqlQuery.Append(" OR ");
//sbFullTextSqlQuery.Append(" (IsDocument = 1 AND ContentClass = 'STS_ListItem_850') ");
//sbFullTextSqlQuery.Append(" OR ");
//sbFullTextSqlQuery.Append(" (ContentClass = 'STS_Web') ");
//sbFullTextSqlQuery.Append(" ) ");
//sbFullTextSqlQuery.Append("ORDER BY ");
//sbFullTextSqlQuery.Append(" Rank DESC ");



//sbFullTextSqlQuery.Append("SELECT ");
//sbFullTextSqlQuery.Append("Title,Abstract, FileExtension, Rank, ContentClass, Path,IsDocument ");
//sbFullTextSqlQuery.Append("FROM ");
//sbFullTextSqlQuery.Append(" SCOPE() ");
//sbFullTextSqlQuery.Append("WHERE ");
//sbFullTextSqlQuery.Append(" FREETEXT(defaultproperties, 'company') ");

_FullTextSqlQuery.QueryText = sbFullTextSqlQuery.ToString();

resultTableCollection = _FullTextSqlQuery.Execute();
}

_SPSite.RootWeb.Dispose();
}
}