Monday, August 22, 2011

The default term store cannot be identified

I was trying to activate the Taxonomy on my site which created from the blank site template.When I connecting and add some properties for "Managed Meta data service" from Central application I have got this error.Initially I have no clue.I googled its WCF hotfix for service application.

when creating the "Enterprise Keyword" column,my term store was not able to find the default term store.
"The default term store cannot be identified"
After tried some attempts to create the same column below error was thrown.
Unrecognized attribute 'allowInSecureTransport'

You can download the hotfix from the below link

Enable Enterprise keywords colum in site

Enabling the "Enterprise Keywords" in sharepoint list or document library.
If you are not seeing this column by default,the reason was you have been selected the blank site to create root site.
There are no way to activate this feature if you selected the blanksite.
You need to activate it through stsadm command

STSADM -o activatefeature -n TaxonomyFieldAdded -url http://myserver
before activating this feature please be make sure you activated the site featured called "SharePoint Server Enterprise Site features"

Sunday, August 21, 2011

SPFolder Collection in SharePoint 2010

This code loop all the folders inside the "Shared Documents" folder.
It will retrieve all the folders inside the Shared documents.I have an requirement to allow the user to upload the documents in to managed folder into Shared Documents and trigger the Workflow.Soon I will post the Workflow code.
public string[] LoopAllFolder()
            string folderName = "";
            SPSite site = SPContext.Current.Site;
            SPFolder cols = site.OpenWeb().Folders[site.Url + "/Shared Documents"];
            if (cols.SubFolders.Count > 0)
                        //SPFileCollection files = cols.Files;
                        SPFolderCollection folders = cols.SubFolders;
                        foreach (SPFolder Colsfolders in folders)
                            folderName = folderName + Colsfolders.Name.ToString() + ",";

            return folderName.TrimEnd(',').Split(',');


I bind these folders in dropdownlist by removing the "Forms" folder.
List FolderList = new List(LoopAllFolder());
            ddlList.DataSource = FolderList;

Wednesday, August 17, 2011

Looping the people picker values

Recently I encountered the strange error while retrieving the all user from the
People picker control using SPQuery.
My datatable comes with Site user id and Name.As I wanted to assign these user to a
specific task in workflow.
while using these first user comes without site user id and the remaining were perfect as i expected.
I should admit,I tried many times but could not figure it out for my first user comes along with site id.Finally I made it to work.

Firstly queried the all user from the people picker control with certain condition using CAML.
 private string GetApproverList()
            using (SPWeb web = workflowProperties.Web)
                string appList = "";
                SPList docApproverList = web.Lists["DocApprovers"];
                string DocType = workflowProperties.Item["DocumentType"].ToString();               
                SPQuery q = new SPQuery();
                //q.Query = q.Query = "" + DocType + "";
                q.Query = "" + DocType + "";
                DataTable dt = docApproverList.GetItems(q).GetDataTable();
                foreach (DataRow row in dt.Rows)
                    appList = appList + row["Approvers"].ToString()+",";
                return appList.TrimEnd(',');

Secondly split this string into array by passing the comma sperator and '#' separator.
 string DocListUser = GetApproverList();
            string[] uids = DocListUser.Split(';', '#');
            for (int a = 0; a < uids.Length; a++)
                if (uids[a].ToString() != "" && !CheckNumber(uids[a].ToString()))

Now I have final string array which comes with "",user id and display name.
public bool CheckNumber(string value)

            int number1;
            return int.TryParse(value, out number1);
I used array list to add each items in above string.Then I omit the "" string and numbers in the array.
 foreach (var userList in uidsList)
                SPUser user = SPContext.Current.Web.EnsureUser(userList.ToString());