Showing posts with label Server Object Model. Show all posts
Showing posts with label Server Object Model. Show all posts

Monday, June 12, 2017

12 Jun

SharePoint List versioning using c#

We can also enable SharePoint List versioning using c# using (SPSite spsite = new SPSite("http://win7/")) { SPWeb spweb = spsite.OpenWeb(); SPList list = spweb.Lists["CustomList"]; list.EnableVersioning = true; list.Update(); } Retrieve SPListItem versions using c# using (SPSite spsite = new SPSite("http://win7/")) { SPWeb...

Wednesday, July 13, 2016

13 Jul

How to change a date format in CAML

We have to add sharepoint Namespace  SPUtility SPUtility.CreateISO8601DateTimeFromSystemDateTime(dateISO...

Wednesday, June 8, 2016

08 Jun

Unique Constraints Programmatically SharePoint

SPSite site = new SPSite("http://peakfinders"); SPWeb web = site.OpenWeb(); SPList custList = web.Lists["Employee"]; SPField vtid = custList.Fields["VoterID"]; vtid.Indexed = true; vtid.EnforceUniqueValues = true; custPhone.Update(...
08 Jun

How to add a user and multi users to the People picker field in a sharepoint list programmtically

Coding:   if (spProjectListItem["USER"] != null)       projectMemberValue = spProjectListItem["USER"].ToString();       SPFieldUserValueCollection oFieldUserValueCollection = new SPFieldUserValueCollection(spDLRWeb,                  ...

Wednesday, March 2, 2016

02 Mar

How to retrieving next 7 Days Due Date Tasks from SharePoint List

C# Coding: DateTime strdate = (DateTime)DateTime.Today.AddDays(7);             string strgetDate = strdate.Year + "-" + strdate.Month + "-" + strdate.Date.Day; SPWeb currentWeb = SPContext.Current.Web;             SPList lst = currentWeb.Lists["Projects"];  ...
02 Mar

How to dynamically Building HTML Table with SharePoint List

NameSapce: Using System.Text Coding: strtxt append any kind text numerics. public void bindata() { try{ SPSecurity.RunWithElevatedPrivileges(delegate()                     {                         StringBuilder...
02 Mar

How to Insert New Item Into SharePoint List Programmatically

using (SPSite spSite = new SPSite(strSiteUrl, token)){spSite.AllowUnsafeUpdates = true;using (SPWeb spWeb = spSite.OpenWeb()){ SPList spList = spWeb.Lists["Enquiry"];SPListItem spListItem = spList.Items.Add(); spListItem["Title"] = "Peak";spListItem["Location"] = "India"; spWeb.AllowUnsafeUpdates = true;  spLis...

Friday, February 12, 2016

12 Feb

When we get retrive People or Group field returning semicolon hash then Name

1;#Deepak Kumar Get User name: new SPFieldLookupValue(properties.ListItem["Staff Member"].ToString()).LookupValue; Get User ID: new SPFieldLookupValue(properties.ListItem["Staff Member"].ToString()).LookupId; Using Split fuction: properties.ListItem["Staff Member"].ToString(); You are going to be returned their...

Tuesday, December 15, 2015

15 Dec

How to update hyperlink filed value in SharePoint List using Server Object Model ?

SPListItem oiitem= oList.GetItemById(itemidvalue);SPFieldUrlValue furl= new SPFieldUrlValue(); furl.URL = "peakfinders.blogspot.in"; furl.Description = "Peak Finders"; oiitem["SiteURL"] = furl ; oiitem.update()...