SharePoint Resource Center has maintained a list of freely available SharePoint tools. These tools are quite useful while working with SharePoint. You can have a look here.
Saturday, November 27, 2010
Thursday, November 25, 2010
“The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service.”, Error while publishing a page in SharePoint 2010.
This was because State Service was not configured in my SharePoint environment.
To configure State Service, I run the following PowerShell script.
Add-PsSnapin Microsoft.SharePoint.PowerShell
$serviceApp = New-SPStateServiceApplication -Name "State Service" New-SPStateServiceDatabase -Name "StateServiceDatabase" -ServiceApplication
$serviceApp New-SPStateServiceApplicationProxy -Name "State Service" -ServiceApplication $serviceApp –DefaultProxyGroup
I added this script in a text file and saved it as script.ps1 on my C drive. Then I opened command prompt and ran this command.
C:\>Powershell C:\script.ps1
After running this script, my State Service was configured and I published my page successfully.Wednesday, November 17, 2010
Error occurred in deployment step 'Recycle IIS Application Pool': Cannot connect to the SharePoint site. Error occurs while deploying SharePoint solution.
In Visual Studio 2010 while deploying SharePoint solutions, sometime we see this error
“Error occurred in deployment step 'Recycle IIS Application Pool': Cannot connect to the SharePoint site. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project.”
This is because we forgot to mention the Site URL where we are going to deploy this solution. After specifying site URL, deployment went well.
Site URL will be your SharePoint site i.e. http://spdev:2000.
Saturday, November 13, 2010
List of Content Types’ IDs in SharePoint 2010
This list provides an overview of Content Types in SharePoint 2010 with their IDs. Content Type ID is essential for maintaining inheritance of Content Types.
Content Type Name | ID |
Administrative Task | 0x010802 |
Announcement | 0x0104 |
Approval Workflow Task (en-US) | 0x01080100C9C9515DE4E24001905074F980F93160003A15057E2AF34B67B32E14B94EB70409 |
Article Page | 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D |
Audio | 0x0101009148F5A04DDD49CBA7127AADA5FB792B006973ACD696DC4858A76371B2FB2F439A |
Basic Page | 0x010109 |
Circulation | 0x01000F389E14C9CE4CE486270B9D4713A5D6 |
Collect Feedback Workflow Task (en-US) | 0x01080100C9C9515DE4E24001905074F980F93160000EEA96BE7C83464C9211129CD27F0409 |
Collect Signatures Workflow Task (en-US) | 0x01080100C9C9515DE4E24001905074F980F93160002E9DB43AC527439AB853AE4FC8360409 |
Comment | 0x0111 |
Contact | 0x0106 |
Discussion | 0x012002 |
Document | 0x0101 |
Document Collection Folder | 0x0120D5 |
DomainGroup | 0x010C |
Dublin Core Columns | 0x01010B |
East Asia Contact | 0x0116 |
Enterprise Wiki Page | 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39004C1F8B46085B4D22B1CDC3DE08CFFB9C |
Event | 0x0102 |
Folder | 0x0120 |
Form | 0x010101 |
Health Analyzer Report | 0x0100F95DB3A97E8046B58C6A54FB31F2BD46 |
Health Analyzer Rule Definition | 0x01003A8AA7A4F53046158C5ABD98036A01D5 |
Holiday | 0x01009BE2AB5291BF4C1A986910BD278E4F18 |
Image | 0x0101009148F5A04DDD49CBA7127AADA5FB792B00AADE34325A8B49CDA8BB4DB53328F214 |
Issue | 0x0103 |
Item | 0x01 |
Link | 0x0105 |
Link to a Document | 0x01010A |
List View Style | 0x010100734778F2B7DF462491FC91844AE431CF |
Master Page | 0x010105 |
Message | 0x0107 |
New Word | 0x010018F21907ED4E401CB4F14422ABC65304 |
Office Data Connection File | 0x010100629D00608F814DD6AC8A86903AEE72AA |
Official Notice | 0x01007CE30DD1206047728BAFD1C39A850120 |
Page | 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39 |
Page Layout | 0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE811 |
Page Output Cache | 0x010087D89D279834C94E98E5E1B4A913C67E |
Person | 0x010A |
Phone Call Memo | 0x0100807FBAC5EB8A4653B8D24775195B5463 |
Picture | 0x010102 |
Post | 0x0110 |
Project Page | 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39004C1F8B46085B4D22B1CDC3DE08CFFB9C 0055EF50AAFF2E4BADA437E4BAE09A30F8 |
Published Link | 0x01004613D6562E4C41A7B9DADDAC1689E00D |
Publishing Approval Workflow Task (en-US) | 0x01080100C9C9515DE4E24001905074F980F9316000A245BAB39C6543159300E33084BA0409 |
Publishing Master Page | 0x0101000F1C8B9E0EB4BE489F09807B2C53288F0054AD6EF48B9F7B45A142F8173F171BD1 |
Redirect Page | 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900FD0E870BA06948879DBD5F9813CD8799 |
Report Builder Model | 0x010100D8704AF8ED734F4088724751E0F2727D |
Report Builder Report | 0x010100C3676CDFA2F24E1D949A8BF2B06F6B8B |
Report Data Source | 0x0101007DFDDF56F8A9492DAA9366B83A95B3A0 |
Reservations | 0x0102004F51EFDEA49C49668EF9C6744C8CF87D |
Resource | 0x01004C9F4486FBF54864A7B0A33D02AD19B1 |
Resource Group | 0x0100CA13F2F8D61541B180952DFB25E3E8E4 |
Reusable HTML | 0x01002CF74A4DAE39480396EEA7A4BA2BE5FB |
Reusable Text | 0x01004D5A79BAFA4A4576B79C56FF3D0D662D |
Rich Media Asset | 0x0101009148F5A04DDD49CBA7127AADA5FB792B |
RootOfList | 0x012001 |
Rule | 0x0100DC2417D125A4489CA59DCC70E3F152B2 |
Schedule | 0x0102007DBDC1392EAF4EBBBF99E41D8922B264 |
Schedule and Reservations | 0x01020072BB2A38F0DB49C3A96CF4FA85529956 |
SharePoint Server Workflow Task | 0x01080100C9C9515DE4E24001905074F980F93160 |
SharePointGroup | 0x010B |
Signatures Workflow Task Deprecated | 0x01080100C9C9515DE4E24001905074F980F9316001 |
Summary Task | 0x012004 |
System | 0x |
System Master Page | 0x0101000F1C8B9E0EB4BE489F09807B2C53288F |
System Page | 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2 |
System Page Layout | 0x01010007FF3E057FA8AB4AA42FCB67B453FFC1 |
Task | 0x0108 |
Timecard | 0x0100C30DDA8EDB2E434EA22D793D9EE42058 |
Universal Data Connection File | 0x010100B4CBD48E029A4AD8B62CB0E41868F2B0 |
Unknown Document Type | 0x010104 |
User Workflow Document | 0x010107 |
Users | 0x0100FBEEE6F0C500489B99CDA6BB16C398F7 |
Video | 0x0101009148F5A04DDD49CBA7127AADA5FB792B00291D173ECE694D56B19D111489C4369D |
Web Part Page | 0x01010901 |
Welcome Page | 0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4 |
Page Layout Content Types | 0x0100A2CA87FF01B442AD93F37CD7DD0943EB |
Wiki Page | 0x010108 |
Workflow History | 0x0109 |
Workflow Task | 0x010801 |
Friday, November 12, 2010
Check programmatically if List is already exists in SharePoint site
While programming with SharePoint Object Model, sometimes we are in situation where we need to check if a list is already exists in given scope especially or we should create a new list. We can check this by creating a list in a try block and if list already exists it will throw exception which will be handled in catch block. However we can check it by other couple of ways.
- Check if lists exists.
- Iterate through collection of lists and match for each list with specified list name.
string listName = "Tasks"; SPSite site = (SPSite)properties.Feature.Parent; SPWeb webName = site.RootWeb; bool isListExixts = webName.Lists.TryGetList(listName); if (isListExixts == true) // List Exists. |
string listName = "Tasks"; SPSite site = (SPSite)properties.Feature.Parent; SPWeb webName = site.RootWeb; SPListCollection listCollection = webName.Lists; foreach (SPList tempList in listCollection) { if (tempList.Title == listName) return true; } |
- Iterate through list of collection using this code.
string listName = "Tasks"; SPSite site = (SPSite)properties.Feature.Parent; SPWeb webName = site.RootWeb; if(webName.Lists.Cast<SPList>().Any(list => list.Title.Equals(listName, StringComparison.OrdinalIgnoreCase))) { return true; } |
Wednesday, November 10, 2010
Create Web Application, Site Collection and Sub Sites through PowerShell in SharePoint 2010
1. Create a .ps1 file and add reference for PowerShell and SharePoint Assemblies.
2. Set variables and create Web Application.Add-PsSnapin Microsoft.SharePoint.PowerShell[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
3. Create Site Collection.#Create Web ApplicationWrite-Output " "
Write-Output "Creating Web Application for Intranet Portal."
$AppName = "Intranet Portall"
$AppPool = "IntranetPortalApplicationPool"
$UserAccount = "winsmarts\sp_admin"
$Port = 80$DBServer = "SPDEV\SQL_SERVER"
$DBName = "IntranetPortalDatabase_80"
New-SPWebApplication -Name $AppName -Port $Port -ApplicationPool $AppPool-ApplicationPoolAccount (Get-SPManagedAccount $UserAccount) -databaseserver $DBServer -databasename $DBNameWrite-Output " "
Write-Output "Web Application Created Successfully."
Write-Output " "
Write-Output "Creating Top Site Collection"
# Set variables$SiteCollectionName = "Test Portal"
$SiteCollectionURL = "http://SPDEV:80"
$SiteCollectionTemplate = "STS#0"
$SiteCollectionLanguage = 1033$SiteCollectionOwner = "winsmarts\Administrator"
# Create a new Sharepoint Site Collection
New-SPSite -URL $SiteCollectionURL -OwnerAlias $SiteCollectionOwner -Language $SiteCollectionLanguage-Template $SiteCollectionTemplate -Name $SiteCollectionNameWrite-Output " "
Write-Output "Top Site Collection created successfully."
4. Create sub sites.
#Creating Sub Sites in top site collection.
Write-Output " "
Write-Output "Creating Sub Sites"
$SubSites = @("Central Services", "Knowledge Base", "Service Center", "IT", "HR", "Finance")for($i=0 ; $i -lt $SubSites.count ; $i++)
{clear-variable -name siteurl$SiteUrl = $SiteCollectionURL += "/"
$SiteUrl = $SiteUrl += $SubSites[$i]Write-Output " "
#Write-Output "Creating Site for " += $SubSites[$i]
Write-Output " "
New-SPWeb $SiteUrl -Template $SiteCollectionTemplate -Name $SubSites[$i] -UseParentTopNav-Language $SiteCollectionLanguageWrite-Output " "
#Write-Output "Site Created for " += $SubSites[$i]
Write-Output " "
}
Sunday, November 7, 2010
“There was a problem retrieving data for this field. Updating values in this field is disabled temporarily. You can still update values in other fields.”, Error while editing User Profile in SharePoint 2010.
When I tried to edit my User Profile in SharePoint 2010, I found some properties disabled with this error, “There was a problem retrieving data for this field. Updating values in this field is disabled temporarily. You can still update values in other fields." This is because Managed Metadata Service Application Proxy’s properties were not properly set.
To resolve this issue, I opened Managed Metadata Service Application Proxy’s properties.
And check first two option.
1. This service application is the default storage location for Keywords.
2. This service application is the default storage location for column specific term sets.
After clicking OK, when I again tried to edit my User Profile properties, everything was working fine.
Thanks to my friend Andreas B.Iversen for telling me this tip.
Monday, November 1, 2010
Create custom User Profile properties in SharePoint 2010 reading from XML file
<Properties Server="http://flhsrv116" TermStore="Managed Metadata Service Application Proxy"> <Property> <Name>Audience</Name> <DisplayName>Audience</DisplayName> <!-- Collection of Values for Type Node : (big integer | binary | boolean | date | date no year | date time | Email | float | unique identifier | HTML | integer | Person | string | string (Single Value) | string (Multi Value) | Time Zone | URL) -->
<Type>string (Multi Value)</Type> <!-- IsMultiValue : Possible Options true | false : Note = Only true when Type = String (Multi Value) --> <IsMultiValue>true</IsMultiValue> <TermStoreGroup>DSG</TermStoreGroup> <TermSet>Audiences</TermSet> </Property> <Property> <Name>DateofJoining</Name> <DisplayName>Date of Joining</DisplayName> <!-- Collection of Values for Type Node : (big integer | binary | boolean | date | date no year | date time | Email | float | unique identifier | HTML | integer | Person | string | string (Single Value) | string (Multi Value) | Time Zone | URL) -->
<Type>date</Type> <!-- IsMultiValue : Possible Options true | false --> <IsMultiValue>false</IsMultiValue> <TermStoreGroup>null</TermStoreGroup> <TermSet>null</TermSet> </Property> </Properties>
In this simple example, I am creating two properties. One is of date type and second is of term set type. This XML file has a root node with two attributes and two child nodes. Each child node represent a custom property. Property’s name, display name, type and other properties can be configured as mentioned above. At the moment, we have only one custom property of term set type in User Profile store.
To do this, create a console application in Visual Studio 2010.
Add references of System.Xml, Microsoft.Office.Server.UserProfiles, Microsoft.SharePoint and Microsoft.SharePoint.Taxonomy if term set type value is required to create.
Add this code in .cs file.
using System;
using Microsoft.Office.Server.UserProfiles;using Microsoft.SharePoint; using Microsoft.SharePoint.Taxonomy; using System.Xml; using System.Collections; namespace UserProfilesOMApp { class Program { static void Main(string[] args) { string str = "UserProfileProperties.xml"; // Reading XML document. XmlDocument doc = new XmlDocument(); doc.Load(str); // Reading Parent node of document. XmlNode xmlNode = doc.DocumentElement; XmlNodeList propertiesxmlnodeList = doc.GetElementsByTagName("Properties"); // Reading Attributes for parent node. XmlElement xmlElement = (XmlElement)propertiesxmlnodeList.Item(0); string servername = xmlElement.GetAttribute("Server"); string termstore = xmlElement.GetAttribute("TermStore"); // Reading property node and its Child node lists. XmlNodeList propertyxmlnodeList = doc.GetElementsByTagName("Property"); XmlNodeList namelist = doc.GetElementsByTagName("Name"); XmlNodeList displaynamelist = doc.GetElementsByTagName("DisplayName"); XmlNodeList typelist = doc.GetElementsByTagName("Type"); XmlNodeList ismultivaluelist = doc.GetElementsByTagName("IsMultiValue"); XmlNodeList termsetlist = doc.GetElementsByTagName("TermSet"); XmlNodeList termstoregrouplist = doc.GetElementsByTagName("TermStoreGroup"); string propertyname = null; string displayname = null; string type = null; string ismultivalue = null; string termstoregroup = null; string termset = null; using (SPSite site = new SPSite(servername)) { for(int x = 0; x < propertyxmlnodeList.Count; x++) { propertyname = namelist.Item(x).InnerText.ToString(); displayname = displaynamelist.Item(x).InnerText.ToString(); type = typelist.Item(x).InnerText.ToString(); ismultivalue = ismultivaluelist.Item(x).InnerText.ToString(); termstoregroup = termstoregrouplist.Item(x).InnerText.ToString(); termset = termsetlist.Item(x).InnerText.ToString(); // Method call for creating a user profile property. Program.createProfileProperties(site, termstore, propertyname, displayname, type, ismultivalue, termstoregroup, termset); } } } static void createProfileProperties(SPSite site, string termstore, string propertyname, string displayname, string type, string ismultivalue, string termstoregroup, string termset) { SPServiceContext context = SPServiceContext.GetContext(site); UserProfileConfigManager upcm = new UserProfileConfigManager(context); try { ProfilePropertyManager ppm = upcm.ProfilePropertyManager; Console.WriteLine("Creating Propoerty"); // Create core property. CorePropertyManager cpm = ppm.GetCoreProperties(); CoreProperty coreproperty = cpm.GetPropertyByName(propertyname); // Check if property already exists. if (coreproperty != null) { Console.WriteLine("Property already exists......"); return; } CoreProperty cp = cpm.Create(false); cp.Name = propertyname; cp.DisplayName = displayname; //Get Property Type from Enumeration. PropertyDataTypeCollection pdtc = upcm.GetPropertyDataTypes(); PropertyDataType ptype = null; IEnumerator enumType = pdtc.GetEnumerator(); while (enumType.MoveNext()) { ptype = (PropertyDataType)enumType.Current; if (ptype.Name.ToString().ToLower().Equals(type.ToString().ToLower())) break; } cp.Type = ptype.Name; if(type.ToLower() == "string (Multi Value)".ToLower()) { cp.IsMultivalued = Convert.ToBoolean(ismultivalue); if (ismultivalue.ToLower() == "true".ToLower()) { cp.Separator = MultiValueSeparator.Semicolon; } // Set the TermSet. TaxonomySession taxonomySession = new TaxonomySession(site); TermStore termStore = taxonomySession.TermStores[termstore]; Group group = termStore.Groups[termstoregroup]; TermSet termSet = group.TermSets[termset]; cp.TermSet = termSet; } cpm.Add(cp); // Create profile type property. ProfileTypePropertyManager ptpm = ppm.GetProfileTypeProperties(ProfileType.User); ProfileTypeProperty ptp = ptpm.Create(cp); ptp.IsVisibleOnViewer = true; ptp.IsVisibleOnEditor = true; ptpm.Add(ptp); // Create profile subtype property. ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context); ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User)); ProfileSubtypePropertyManager pspm = ps.Properties; ProfileSubtypeProperty psp = pspm.Create(ptp); psp.PrivacyPolicy = PrivacyPolicy.OptIn; psp.DefaultPrivacy = Privacy.NotSet; pspm.Add(psp); Console.WriteLine("\nuser profile property "+ displayname + " created successfully.\n"); Console.ReadKey(); } catch (DuplicateEntryException e) { Console.WriteLine(e.Message); Console.Read(); } catch (System.Exception e2) { Console.WriteLine(e2.Message); Console.Read(); } } } }
After running this code, this output will come.
Now, in User Profile store, two custom properties has been added.
Download project solution as zip file.