Wednesday, June 16, 2010

Creating site columns thorugh SQL query

Sometimes, you may feel pain while creating site columns and content types through CAML, because you need to know CAML syntax for each and every site column data type, but you can avoid this by simply running one sql queryNormally in SharePoint when we create any site column or content type through SharePoint user interface that will go and stored into content database in the form of CAML, so we can run simple sql query and get that data and build it into features and deploy the same in some other environment means productionSteps1. create sitecoumns...

Friday, June 11, 2010

Access denied error when code runs with SPsecurity.RunWithElevatedPriviliges

Today, while reviewing code ,I have found some thing, which will give access denied error if our code runs with SPSecurity.RunWithElevatedPriviliges and AllowUnsafeUpdates = trueCheck the piece of code which I have written below that gives access denied errorusing (SPSite site = new SPSite(SPContext.Current.Web)){SPList list = web.Lists[listUrl];SPFieldCollection fieldCol = list.Fields;SPListItem newItem = list.Items.Add();foreach (SPField field in fieldCol){if (!field.Hidden && !field.ReadOnlyField){if (field.Title.Equals(question, StringComparison.OrdinalIgnoreCase)){newItem[field.Title]...