Monday, December 8, 2014
Announcments List ,calender Lists, Tasks Lists are not displaying in SharePoint 2010, 2013
Posted by
Santhosh,
on
4:16 AM
Hi Guys ,
Thanks for visiting my blog.
Today i came across a situation where am trying to create a Calender List but am not able to see the templates under view all site content.After a bit of trouble shoot i found the answer to this question.
Answer : Go to SiteActions
-->Site Settings
-->Site Actions
-->Manage Site features
--->Group Work List(Activate this feature).
Thanks for visiting my blog.
Today i came across a situation where am trying to create a Calender List but am not able to see the templates under view all site content.After a bit of trouble shoot i found the answer to this question.
Answer : Go to SiteActions
-->Site Settings
-->Site Actions
-->Manage Site features
--->Group Work List(Activate this feature).
Thursday, December 4, 2014
How to get User data from Active Directory in SharePoint in C#
Posted by
Santhosh,
on
4:33 AM
Hi Guys,
Thanks for visiting my blog .
In this Post , Am going to get User data from Active Directory in C# .We can also use the code in SharePoint also as per the requirement.
Please find the code for getting user details from AD (Active directory ).
Before writing the code We need to get System.DirectoryServices dll from assembiles. ino the page.
Best Practice : Get the Server Name from Web.config file .
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
string connection = "LDAP:// server name"; // LDAP Server Name
DirectorySearcher dssearch = new DirectorySearcher(connection);
dssearch.Filter = "(sAMAccountName=" + txtusername.Text + ")"; // Passing UserName
SearchResult sresult = dssearch.FindOne();
DirectoryEntry dsresult = sresult.GetDirectoryEntry(); // retrieving data
string FirstName = dsresult.Properties["givenName"][0].ToString();
string LastName = dsresult.Properties["sn"][0].ToString();
string EmailID = dsresult.Properties["mail"][0].ToString();
}
catch (Exception ex)
{
}
}
How To: Save publishing site as a template in SharePoint 2010 and 2013
Posted by
Santhosh,
on
2:36 AM
Hi Guys,
Thanks for visiting my blog.
Many of you must have noticed that the “Save site as template menu” under “Look and Feel” site settings category is missing for publishing site.
Solution :
One of the old and well known workarounds for this was to directly navigate to “_layouts/savetmpl.aspx” application page and save the site Template. This workaround however does not work as expected in SharePoint 2013 sites.
Regarding to fix it we need to enable SaveSiteAsTemplateEnabled to true
for more information "http://www.learningsharepoint.com/2013/05/03/missing-save-site-as-template-for-publishing-sites-in-sharepoint-2013/"
“Save site as template” menu option was removed from publishing sites?
According to my vast experience with many customer that are using publishing sites, a lot of them tried to use the save as template option (some using code, some using a feature like the one below) and we all came to the same conclusion:Since publishing sites has pages in them and layouts that are all connected to a content type that is configured at the top level site of the site collection, and because these content types are not saved and moved within the site template STP file – this makes the STP file not self-describing as it should.
This means that if you save a publishing site as template and use it in the same site collection, providing all site content types it uses were not changed, it will work OK.
The problem is when you try to move it to a different site collection, or when you changed or deleted some content types in your current site collection – this will result in an un expected behaviour (that is from my experience mend-able with some work).
Note : Other than Publishing Site we can find the " Save Site as Template " available under look and feel in Site Settings .
Monday, December 1, 2014
How to get multiple users from Sharepoint list through programatically (C#).
Posted by
Santhosh,
on
2:00 AM
Hi Guys ,
Thanks for visiting to my blog .
Background or scenario:
Some times we come across a situation where in we have to get multiple users data from SharePoint list and use the details as per the requirment. (My requirment is getting users mail ids and send them mail at one shot).
Note : If people picker selects multiple users then only we can use the below code .
we can get the users data using C# server object model .
String strCCEmail =String.Empty();
SPList listObject=Spweb.Lists.TrygetList("Listname");
SPFieldUser UsersColumn = (SPFieldUser)listObject.Fields.GetField("CoulmName");
SPFieldUserValueCollection Users = (SPFieldUserValueCollection)UsersColumn.GetFieldValue(lstitemCollection[0]["CoulmName"].ToString());
if (Users != null)
{
foreach (SPFieldUserValue user in Users)
{
SPUser spUser = user.User;
if (spUser != null)
strCCEmail = strCCEmail + ";" + spUser.Email;
}
strCCEmail = strCCEmail.TrimStart(';');
}
Thanks for visiting to my blog .
Background or scenario:
Some times we come across a situation where in we have to get multiple users data from SharePoint list and use the details as per the requirment. (My requirment is getting users mail ids and send them mail at one shot).
Note : If people picker selects multiple users then only we can use the below code .
we can get the users data using C# server object model .
String strCCEmail =String.Empty();
SPList listObject=Spweb.Lists.TrygetList("Listname");
SPFieldUser UsersColumn = (SPFieldUser)listObject.Fields.GetField("CoulmName");
SPFieldUserValueCollection Users = (SPFieldUserValueCollection)UsersColumn.GetFieldValue(lstitemCollection[0]["CoulmName"].ToString());
if (Users != null)
{
foreach (SPFieldUserValue user in Users)
{
SPUser spUser = user.User;
if (spUser != null)
strCCEmail = strCCEmail + ";" + spUser.Email;
}
strCCEmail = strCCEmail.TrimStart(';');
}
How to get list of tables from Database in SQL Server.
Posted by
Santhosh,
on
1:40 AM
Hi Guys ,
Thanks for visiting my blog .
Some times we come across a situation where we want to know list of tables in database
Type this command in SAL editor and press F5(or run the command).
USE SampleDB
SELECT * FROM SYS.tables.
How to Export and Import Sub Site in SharePoint using stsadm Commands
Posted by
Santhosh,
on
1:25 AM
Hi Guys,
Thanks for visiting my blog .
In this Post ,am going to show "How to Export and Import Sub Site in SharePoint using stsadm Commands"
Step 1 : Open ---> "C Drive : WebserverExtension\15\Bin ".
Step 2 : stsadm -o export -url "SiteURL/Subsite" -filename SubSiteName-includeusersecurity.
(A backup file of site creates in bin folder with Sitename).
Step 3: stsadm -o import -url "SiteURL/Subsite" -filename SubSiteName-includeusersecurity.
Note : After restoring if you get an error like pages are not coming then the issue would be
master pages .
Source Site (master page) and Destination Site Master Page must have to be same .
Thanks for visiting my blog .
In this Post ,am going to show "How to Export and Import Sub Site in SharePoint using stsadm Commands"
Step 1 : Open ---> "C Drive : WebserverExtension\15\Bin ".
Step 2 : stsadm -o export -url "SiteURL/Subsite" -filename SubSiteName-includeusersecurity.
(A backup file of site creates in bin folder with Sitename).
Step 3: stsadm -o import -url "SiteURL/Subsite" -filename SubSiteName-includeusersecurity.
Note : After restoring if you get an error like pages are not coming then the issue would be
master pages .
Source Site (master page) and Destination Site Master Page must have to be same .
Create Site Column Using Power Shell and Server Object Model as well.
Posted by
Santhosh,
on
1:05 AM
Hi Guys,
Thanks for visiting my blog .
In one of my previous posts i have created Site Column in SharePoint Site using Out of box feature.
In my current post ,am going to create a Site Column using Power Shell Script and Server object Model as well.
First , I will show the Power Shell Script to create a site Column .
$site = Get-SPSite -Identity "Site URL" // Add the Site URL here
$web = $site.RootWeb
$fieldXML = '<Field Type="Text"
Name="EmpName"
Description="Employee Name Column Info."
DisplayName="EmpName"
Group="EmployeeInformation"
Hidden="FALSE"
Required="FALSE"
ShowInDisplayForm="TRUE"
ShowInEditForm="TRUE"
ShowInListSettings="TRUE"
ShowInNewForm="TRUE"></Field>'
$web.Fields.AddFieldAsXml($fieldXML)
$web.Dispose()
$site.Dispose()
Note : Save the Script in notepad and save the text file with .ps1 extension in drive .
Copy the Script location with extension.
Open-->Power Shell(Run As Administrator)
Now you can check the site Column created under Group "EmployeeInformation".
Second , I will show how to create a site Column using C# (Programatically)..
private static void CreateSiteColumn()
{
try
{
string SiteColumnName = "IndiaMyCountry";
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("Server URL"))
{
SPWeb web = site.RootWeb;
//Create Site Column
//Add choice Field "India"
if (!web.Fields.ContainsField(SiteColumnName))
{
string countryField = web.Fields.Add(SiteColumnName, SPFieldType.Choice, true);
//Set the Field Properties
SPFieldChoice CityInIndia =(SPFieldChoice)web.Fields.GetField(SiteColumnName);
//Set the group for the Site column
CityInIndia.Group = "States";
//Add the choices
string[] States = new string[] { "TamilNadu", "Kerala", "Andhr Pradesh","karnataka"};
CityInIndia.Choices.AddRange(States);
//Set the default value
CityInIndia.DefaultValue = "TamilNadu";
//Set Fillable value
CityInIndia.FillInChoice = true;
//Update the field
CityInIndia.Update();
}
}
});
}
catch (Exception ex)
{
throw ex;
}
}
Thanks for visiting my blog .
In one of my previous posts i have created Site Column in SharePoint Site using Out of box feature.
In my current post ,am going to create a Site Column using Power Shell Script and Server object Model as well.
First , I will show the Power Shell Script to create a site Column .
$site = Get-SPSite -Identity "Site URL" // Add the Site URL here
$web = $site.RootWeb
$fieldXML = '<Field Type="Text"
Name="EmpName"
Description="Employee Name Column Info."
DisplayName="EmpName"
Group="EmployeeInformation"
Hidden="FALSE"
Required="FALSE"
ShowInDisplayForm="TRUE"
ShowInEditForm="TRUE"
ShowInListSettings="TRUE"
ShowInNewForm="TRUE"></Field>'
$web.Fields.AddFieldAsXml($fieldXML)
$web.Dispose()
$site.Dispose()
Note : Save the Script in notepad and save the text file with .ps1 extension in drive .
Copy the Script location with extension.
Open-->Power Shell(Run As Administrator)
Now you can check the site Column created under Group "EmployeeInformation".
Second , I will show how to create a site Column using C# (Programatically)..
private static void CreateSiteColumn()
{
try
{
string SiteColumnName = "IndiaMyCountry";
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("Server URL"))
{
SPWeb web = site.RootWeb;
//Create Site Column
//Add choice Field "India"
if (!web.Fields.ContainsField(SiteColumnName))
{
string countryField = web.Fields.Add(SiteColumnName, SPFieldType.Choice, true);
//Set the Field Properties
SPFieldChoice CityInIndia =(SPFieldChoice)web.Fields.GetField(SiteColumnName);
//Set the group for the Site column
CityInIndia.Group = "States";
//Add the choices
string[] States = new string[] { "TamilNadu", "Kerala", "Andhr Pradesh","karnataka"};
CityInIndia.Choices.AddRange(States);
//Set the default value
CityInIndia.DefaultValue = "TamilNadu";
//Set Fillable value
CityInIndia.FillInChoice = true;
//Update the field
CityInIndia.Update();
}
}
});
}
catch (Exception ex)
{
throw ex;
}
}
Subscribe to:
Posts
(
Atom
)