Showing posts with label SharePoint 2007. Show all posts
Showing posts with label SharePoint 2007. Show all posts

Tuesday, April 26, 2016

Hide column headings in SharePoint Views

If you want to hide column headings in a sharepoint view which you have sitting on your home page (or any other page for that matter) Perform following actions

1. Edit Page and Add a Script Editor webpart from Media and Content section.

2. Once the Script Editor webpart is added (make sure that the webpart is the last webpart on the page (bottom most). Edit the webpart and click EDIT SNIPPET

3. Add following script in the editor

4. Click OK on the webpart properties and Save the page.

Tuesday, February 22, 2011

How to enable SharePoint Designer Workflows

We know that there are 3 types of workflows


  • Out of the box workflows

  • SharePoint Designer workflows

  • Custom workflows using Visual Studio and Workflow Foundation (WF)

By default SharePoint Designer workflows are enabled on a site in SharePoint 2007 (MOSS) but if you want to change the default settings (or if they are disabled) follow these steps



  1. Open Central Administration.

  2. Click Application Management tab.

  3. Under Workflow Management Section, click Workflow settings.

  4. Make sure you have selected the web application on which you want to perform the operation

  5. Click Yes or No for "Enable user-defined workflows for this site?" depending on your requirement.

Note: Users with Web Designer permissions can create and deploy workflows by using the Workflow Designer wizard in Office SharePoint Designer 2007.

Wednesday, February 16, 2011

CAML Query

CAML stands for Collaborative Application Markup Language. This language within the context of Microsoft SharePoint Services/Foundation to define query against list data.
To simplify things, as we have SQL to perform operations of SQL Server, we have CAML to perform operations on List.
Note: With SQL, we can perform a lot more complex operations which we cannot perform in CAML.

CAML is XML like structure with some of the schema elements defined below
WHERE <Where> </Where> Just like WHERE Clause in SQL but unlike SQL where we have WHERE mostly coming in last, here our query starts with a WHERE Clause.
AND <And> </And> Just like AND Clause in SQL but as explained above, its a XML like schema so every criteria has to be inside AND Tags.
OR <Or> <Or> Similar to OR Clause in SQL but XML like schema.
EQ <Eq> <Eq> Represents a "=" (Equals To)
NEQ <Neq> <Neq> Represents a "!=" (Not Equals To)
GT <gt > <gt > Represents a ">" (Greater Than)
LT <lt > <lt > Represents a "<" (Less Than)
FieldRef <FieldRef> <FieldRef> Can be considered as a column in SQL Server but with different attributes

A standard CAML QUERY
<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>Hello World</Value></Eq></Where>
More on CAML in next post

Tuesday, February 15, 2011

Programmatically add records in a List in SharePoint

using Microsoft.SharePoint;

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("SITE URL"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["LIST NAME"];
web.AllowUnsafeUpdates = true;
SPListItem item = list.Items.Add();
item["TITLE"] = "Hello World";
item.Update();
list.Update();
web.AllowUnsafeUpdates = false;
}
}
});

Now for some explanation :

using Microsoft.SharePoint; This namespace is added at the start of the .cs file to use available classes. We have to first add a reference to Microsoft.SharePoint.dll file by right clicking your solutions/project/web application and selecting Add Reference option.
If you are working on SharePoint 2007 (MOSS) browse to 12 hive and then to ISAPI folder and select Microsoft.SharePoint.dll (C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\ISAPI). If you are working on SharePoint 2010, the folder is 14.

After adding reference importing the required namespace, we have a Security Context

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("SITE URL"))
{
using (SPWeb web = site.OpenWeb())
{
/
/do something there
}
}
});

If you are logged in as a user who does not have rights to perform any insert operation, we elevate privileges. This feature is provided in Windows SharePoint Services 3.0 to perform actions in code programmatically using an increased level of privilege.

using scope is introduced so that as soon as SPSite and SPWeb objects gets out of context, they are disposed of automatically

SPSite site = new SPSite("SITE URL")We first open the site in which we have the list on which we want to perform insert operation.

SPWeb web = site.OpenWeb()We open the web in which we have the list of which we want to perform insert operation.
SPList list = web.Lists["LIST NAME"];Now we create object of SPList Class with the list in which we have to perform insert operation. "LIST NAME" is the name of the list which needs to be accessed from your code.

web.AllowUnsafeUpdates = true; We get security validation errors if we do not set our web for AllowUnSafeUpdates.

SPListItem item = list.Items.Add();SPList class is collection of list items. Just like any other collection, say DataTable for instance, whenever we want to add a new item to collection, we call the Add method to return SPListItem object. Simply speaking, this object represents a row in the SPList list.

item["TITLE"] = "Hello World"; As we discussed above that SPListItem instance represents a row in your list, now you can access columns/fields and set valid values in them.

item.Update();
list.Update();
web.AllowUnsafeUpdates = false;After setting the values, we update our item, we finally update our list which inserts data in the list. We initially set web.AllowUnsafeUpdates to true to avoid errors. Now we are done with our insert operation, its better to set it to false again.
The code will automatically move to the next statement which is closing braces of our using block which disposes our SPWeb and SPSite objects.

Tuesday, January 25, 2011

How to identify which version of SharePoint you are using

It first seems obvious that you know what version of SharePoint you are using.
When I say version, I dont mean if you are using 2007 or 2010, I mean to say if you are using Express, Standard or Enterprise.

To find what version you are using in SharePoint 2007 (MOSS),
  • Go to Central Administration
  • Click Site Actions
  • Click Site Settings
  • Under Site Information you will see that version is installed

To find what version you are using in SharePoint 2010,
  • Run SharePoint 2010 Management Shell (Power Shell)
  • Run the command get-spfarm | Select Products
You will get all Products listed

For a complete list of Product GUID

SharePoint Foundation 2010: BEED1F75-C398-4447-AEF1-E66E1F0DF91E 
Search Server Express 2010: 1328E89E-7EC8-4F7E-809E-7E945796E511 
SharePoint Server 2010 Standard Trial: B2C0B444-3914-4ACB-A0B8-7CF50A8F7AA0 
SharePoint Server 2010 Standard: 3FDFBCC8-B3E4-4482-91FA-122C6432805C 
SharePoint Server 2010 Enterprise Trial: 88BED06D-8C6B-4E62-AB01-546D6005FE97 
SharePoint Server 2010 Enterprise: D5595F62-449B-4061-B0B2-0CBAD410BB51 
Search Server 2010 Trial: BC4C1C97-9013-4033-A0DD-9DC9E6D6C887 
Search Server 2010: 08460AA2-A176-442C-BDCA-26928704D80B 
Project Server 2010 Trial: 84902853-59F6-4B20-BC7C-DE4F419FEFAD 
Project Server 2010: ED21638F-97FF-4A65-AD9B-6889B93065E2 
Office Web Companions 2010: 926E4E17-087B-47D1-8BD7-91A394BC6196

Reference:

Thursday, January 20, 2011

Missing PDF Icon in SharePoint 2010

Notice when you upload a PDF file in document library of your SharePoint 2010 site, the icon is not there. SharePoint does not have the definition for icon of PDF files.

To get the document library show PDF or any other icons, follow these steps
  1. Open folder [drive]\Program Files\Common Files\Microsoft Shared\Web server extensions\14\Template\Images.
  2. Copy PDF icon in this folder. (You can get PDF icon from http://www.adobe.com/misc/linking.html. It is recommended to download 17 x 17' )
  3. Stop IIS by running iisreset/stop on command prompt.
  4. Open folder [drive]\Program Files\Common Files\Microsoft Shared\Web server extensions\14\Template\Xml
  5. Make a copy of DocIcon.xml file.
  6. Open DocIcon.xml and add < Mapping Key="pdf" Value="[Name-Of-Icon-File.gif]" />
  7. Save and close DocIcon.xml file.
  8. Start IIS again by running iisreset/start on command prompt.

Now go to your document library where you uploaded PDF file and verify the icon.


Note:
For SharePoint Portal Server 2003: Use 60 in place of 14
For SharePoint Portal Server 2007: Use 12 in place of 14