Monday, December 8, 2014

List Creation in SharePoint

SPSite site = SPContext.Current.Site;
SPWeb web = site.RootWeb;
web.AllowUnsafeUpdates = true;
#Creating new custom list Guid listId = web.Lists.Add(
"List name user defined",
"Create custom list description", SPListTemplateType.GenericList
);
SPList list = web.Lists[listId];
web.AllowUnsafeUpdates = false;



string siteUserName="nam",_siteurl="http://sharepoint.com",_sitepassword ="pass@word1";

ClientContext clientContext = new ClientContext(_siteurl);
 clientContext.AuthenticationMode =ClientAuthenticationMode.Default;
 clientContext.Credentials = new System.Net.NetworkCredential(_siteUserName, _sitepassword, _domainName);
  Web oweb = clientContext.Web;

ListCreationInformation lci = ListCreationInformation();
                           lci.Description = "Test";
                           lci.Title = "TestName";
                           lci.TemplateType = 101;
                           SharePointclientObj.List newLib = clientContext.Web.Lists.Add(lci);
                           clientContext.Load(newLib);

                           clientContext.ExecuteQuery();

$().SPServices({ operation: "GetUserInfo",
async: false,
userLoginName: $().SPServices.SPGetCurrentUser(),
completefunc: function (xData, Status) {
$(xData.responseXML).find("User").each(function() {
curUserId = $(this).attr("ID");
curUserName = $(this).attr("Name");
curFullUserName = $(this).attr("ID")+";#"+$(this).attr("Name");
});
} }); alert(curUserId);

$web = Get-SPWeb "http://testurl/" $user = $web.EnsureUser("domainname\Raghu") $id = $user.ID

No comments:

Post a Comment