You can create site template using SharePoint site setting UI. alternatively you could PowerShell
$Web=Get-SPWeb http://sp2013.com/sites/template
$Web.SaveAsTemplate("Template Name","Template Title","Template Description",1)
If you want to save specified site as template along with data use 1, otherwise use 0 in forth parameter of SaveAsTemplate().
After running above commands, the newly created template will be available in site collection "Solutions" gallery.
Wednesday, April 16, 2014
ReDeploy Custom Timer Job using PowerShell
Following are the steps you need to redeploy a custom timer job.
Disable-SPFeature -Identity "91b81920-cc93-46da-b2c9-7e29c5077a67" -Url "http://sp2013.com/"
UnInstall-SPFeature -Identity "91b81920-cc93-46da-b2c9-7e29c5077a67"
Uninstall-SPSolution -Identity TimerJob.wsp –allwebapplications
Remove-SPSolution TimerJob.wsp –force
Add-spsolution C:\temp\TimerJob.wsp
Install-spsolution TimerJob.wsp -GACDeployment –force
Enable-SPFeature -Identity "91b81920-cc93-46da-b2c9-7e29c5077a67" -Url "http://sp2013.com/" –PassThru
Stop-Service SPTimerV4
Start-Service SPTimerV4
If you use update solution TimerJob may not pickup updated functionality
//Update-SPSolution -Identity timerjob.wsp -LiteralPath C:\temp\TimerJob.wsp -GACDeployment
Disable-SPFeature -Identity "91b81920-cc93-46da-b2c9-7e29c5077a67" -Url "http://sp2013.com/"
UnInstall-SPFeature -Identity "91b81920-cc93-46da-b2c9-7e29c5077a67"
Uninstall-SPSolution -Identity TimerJob.wsp –allwebapplications
Remove-SPSolution TimerJob.wsp –force
Add-spsolution C:\temp\TimerJob.wsp
Install-spsolution TimerJob.wsp -GACDeployment –force
Enable-SPFeature -Identity "91b81920-cc93-46da-b2c9-7e29c5077a67" -Url "http://sp2013.com/" –PassThru
Stop-Service SPTimerV4
Start-Service SPTimerV4
If you use update solution TimerJob may not pickup updated functionality
//Update-SPSolution -Identity timerjob.wsp -LiteralPath C:\temp\TimerJob.wsp -GACDeployment
GAC Install a DLL using PowerShell
Installed assembly into GAC -
Set-location "c:\temp"
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacInstall("C:\temp\Mydll.dll")
iisreset
To Get assembly info-
([system.reflection.assembly]::loadfile("C:\temp\Mydll.dll")).FullName
Set-location "c:\temp"
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacInstall("C:\temp\Mydll.dll")
iisreset
To Get assembly info-
([system.reflection.assembly]::loadfile("C:\temp\Mydll.dll")).FullName
SharePoint 2013 URLs
We can access SharePoint pages using their shortcuts URLs
Add Web Parts Pane - ?ToolPaneView=2
Add web parts to any page - ?PageView=Shared&ToolPaneView=2
Create Alerts on this Site - _layouts/15/SubChoos.aspx
Create New new list, library etc - _layouts/15/create.aspx
Create New Site - _layouts/15/NewsbWeb.aspx
Create New Web Part Page - _layouts/15/spcf.aspx
Edit Alerts - _layouts/15/SubEdit.aspx
List Template Gallery - _catalogs/lt/Forms/AllItems.aspx
Login as another user - /_layouts/closeConnection.aspx?loginasanotheruser=true
Manage People - _layouts/15/people.aspx
Manage Permissions - _layouts/15/user.aspx
Manage SiteCollection Administrators - _layouts/15/mngsiteadmin.aspx
Manage Sites and Workspaces - _layouts/15/mngsubwebs.aspx
Master Page Gallery - _catalogs/masterpage/Forms/AllItems.aspx
Modify Navigation - _layouts/15/AreaNavigationSettings.aspx
Navigation Settings - _layouts/15/SiteNavigationSettings.aspx
Recycle Bin - _layouts/15/AdminRecycleBin.aspx
Save Site as Template - _layouts/15/savetmpl.aspx
Site Column Gallery - _layouts/15/mngfield.aspx
Site Content and Structure Manager - _layouts/15/sitemanager.aspx
Site Content Types - _layouts/15/mngctype.aspx
Site Directory - _layouts/15/SiteDirectorySettings.aspx
Site Settings page - _layouts/15/settings.aspx
User Alerts -_layouts/15/sitesubs.aspx
User Information List - _catalogs/users/simple.aspx
View All Site Content - _layouts/15/viewlsts.aspx
Web Part Gallery - _catalogs/wp/Forms/AllItems.aspx
Web part maintenance mode - ?contents=1 to Page URL
Web Analytics Reports Summary - _layouts/15/usage.aspx
Add Web Parts Pane - ?ToolPaneView=2
Add web parts to any page - ?PageView=Shared&ToolPaneView=2
Create Alerts on this Site - _layouts/15/SubChoos.aspx
Create New new list, library etc - _layouts/15/create.aspx
Create New Site - _layouts/15/NewsbWeb.aspx
Create New Web Part Page - _layouts/15/spcf.aspx
Edit Alerts - _layouts/15/SubEdit.aspx
List Template Gallery - _catalogs/lt/Forms/AllItems.aspx
Login as another user - /_layouts/closeConnection.aspx?loginasanotheruser=true
Manage People - _layouts/15/people.aspx
Manage Permissions - _layouts/15/user.aspx
Manage SiteCollection Administrators - _layouts/15/mngsiteadmin.aspx
Manage Sites and Workspaces - _layouts/15/mngsubwebs.aspx
Master Page Gallery - _catalogs/masterpage/Forms/AllItems.aspx
Modify Navigation - _layouts/15/AreaNavigationSettings.aspx
Navigation Settings - _layouts/15/SiteNavigationSettings.aspx
Recycle Bin - _layouts/15/AdminRecycleBin.aspx
Save Site as Template - _layouts/15/savetmpl.aspx
Site Column Gallery - _layouts/15/mngfield.aspx
Site Content and Structure Manager - _layouts/15/sitemanager.aspx
Site Content Types - _layouts/15/mngctype.aspx
Site Directory - _layouts/15/SiteDirectorySettings.aspx
Site Settings page - _layouts/15/settings.aspx
User Alerts -_layouts/15/sitesubs.aspx
User Information List - _catalogs/users/simple.aspx
View All Site Content - _layouts/15/viewlsts.aspx
Web Part Gallery - _catalogs/wp/Forms/AllItems.aspx
Web part maintenance mode - ?contents=1 to Page URL
Web Analytics Reports Summary - _layouts/15/usage.aspx
Monday, November 18, 2013
Retrieve user properties and Group Memberships from Profile database of User Profile Service - SharePoint 2010
SQL Queries
-
Use this query to see the one or multiple user’s
properties from Profile Database.
SELECT UserProfile.NTName, PropList.PropertyName, UserProfileVal.PropertyVal
FROM [dbo].[UserProfile_Full] UserProfile
WITH(NOLOCK)
JOIN [dbo].[userProfileValue] UserProfileVal
ON
UserProfileVal.RecordID = UserProfile.RecordID
JOIN [dbo].[PropertyList] PropList
ON
PropList.PropertyID = UserProfileVal.PropertyID
WHERE UserProfile.NTName IN ('domain\user1', 'domain\user2')
Use this query to find the membership of a user
in various AD groups.
SELECT UserProfile.NTName, UserProfile.PreferredName, MemberGrp.Displayname
FROM
[dbo].[UserProfile_Full] UserProfile
WITH(NOLOCK)
JOIN [dbo].UserMemberships UserMembership
ON
UserProfile.RecordID = UserMembership.RecordID
JOIN [dbo].Membergroup MemberGrp
ON UserMembership.Membergroupid = MemberGrp.id
where
UserProfile.NTName like '%domain\user1%'
Tuesday, November 12, 2013
SharePoint Form Fields and jQuery
Get or Set values/attributes of SharePoint Form Fields using JQuery.
Question 1: From where to download JQuery Base Library?
Answer 1: http://code.jquery.com/
Answer 1: http://code.jquery.com/
Question 2: How to include JQuery Script?
Answer 2: Upload the JQuery base library to the Assets list and include the library using the below syntax
<script type="text/javascript" src="../../Assets/jquery-1.10.2.min.js"></script>
Answer 2: Upload the JQuery base library to the Assets list and include the library using the below syntax
<script type="text/javascript" src="../../Assets/jquery-1.10.2.min.js"></script>
Question 3: What attribute to use for getting the INPUT object?
Answer 3: We need to use the title attribute of the INPUT control
Answer 3: We need to use the title attribute of the INPUT control
<input
name="ctl00$m$g_e2bcfa9c_6e16_4b44_9833_22e44201a72b$ctl00$ctl04$ctl03$ctl00$ctl00$ctl04$ctl00$ctl00$TextField"
type="text" maxlength="255"
id="ctl00_m_g_e2bcfa9c_6e16_4b44_9833_22e44201a72b_ctl00_ctl04_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_TextField"
title="Email" class="ms-long" />
Question 4: How to write JQuery function?
Answer 4:
Answer 4:
<script type="text/javascript"
src="../../Assets/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
<script type="text/javascript">
$(document).ready(function () {
});
</script>
Note: $(document).ready(function ()... is referred as
the MAIN() function
Question 5: How to get the value of the INPUT field?
Answer 5: var variablename = $("input[title='title of the input control']").val();
Answer 5: var variablename = $("input[title='title of the input control']").val();
Question 6: How to make the field readonly?
Answer 6: $("input[title='title of the input control']").attr("readonly","true");
Answer 6: $("input[title='title of the input control']").attr("readonly","true");
Question 7: How to get the value of the Dropdown?
Answer 7: var variablename = $("select[title='title of the dropdown control']").val();
Answer 7: var variablename = $("select[title='title of the dropdown control']").val();
Question 8: How to set the value to the text field?
Answer 8: $("input[title='title of the input control']").val("enter value here");
Answer 8: $("input[title='title of the input control']").val("enter value here");
Question 9: How to remove the readonly of the text field?
Answer 9: $("input[title='title of the input control']").removeAttr("readonly");
Answer 9: $("input[title='title of the input control']").removeAttr("readonly");
Question 10: How to set focus to the text field?
Answer 10: $("input[title='title of the input control']").focus();
Answer 10: $("input[title='title of the input control']").focus();
Question 11: How to use JQuery in PreSaveAction or PreSaveItem?
Answer 11:
<script type="text/javascript" src="../../Assets/jquery-1.10.2.min.js"></script>
<script language = "Javascript">
function PreSaveAction()
{
Answer 11:
<script type="text/javascript" src="../../Assets/jquery-1.10.2.min.js"></script>
<script language = "Javascript">
function PreSaveAction()
{
var variablename = $("input[title='title of the input
control']").val();
}
</script>
Note: do not include $(document).ready(function ()...
Question 12: How to call JQuery function in Dropdown value change?
Answer 12:
<script type="text/javascript" src="../../Assets/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
Answer 12:
<script type="text/javascript" src="../../Assets/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("select[title='title of the
control']").change(function () {
//write logic here
});
});
</script>
//write logic here
});
});
</script>
Question 13: How to set the width of the Text field?
Answer 13: $("input[title='title of the control']").width(100);
Answer 13: $("input[title='title of the control']").width(100);
Question 14: How to disable Textfield?
Answer 14: $("input[title='title of the control']").attr('disabled','disabled');
Question 15: How to Remove disable attribute on Textfield?
Answer 15: $("input[title='title of the control']").removeAttr('disabled');
Answer 14: $("input[title='title of the control']").attr('disabled','disabled');
Question 15: How to Remove disable attribute on Textfield?
Answer 15: $("input[title='title of the control']").removeAttr('disabled');
Question 16: How to check numeric value in Text field?
Answer 16:
var numbervaluefield = $("input[title='title of the control']").val();
var numericheckvaariable = $.isNumeric(numbervaluefield);
Answer 16:
var numbervaluefield = $("input[title='title of the control']").val();
var numericheckvaariable = $.isNumeric(numbervaluefield);
Note: The function will
return boolean value
Question 17: How to compare date in Jquery?
Answer 17:
Answer 17:
var startdate = new Date($("input[title='Start
Date']").val());
var enddate = new Date($("input[title='End Date']").val());
var enddate = new Date($("input[title='End Date']").val());
if(enddate < startdate)
{
alert("End Date cannot be lesser than Start date.");
$("input[title='End Date']").focus();
return false;
}
else
{
{
alert("End Date cannot be lesser than Start date.");
$("input[title='End Date']").focus();
return false;
}
else
{
return true;
}
}
Question 18: How to set default value in Rich Text field?
Answer 18:
Answer 18:
<script
type="text/javascript"
src="../../Assets/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var htmlcontentval = "<table border='1' cellpadding='0' cellspacing='0'><tr><td colspan='3'>Month-Year</td></tr><tr><td>Milestone</td> <td>Onsite Effort</td><td>Offshore Effort</td></tr><tr><td> </td><td> </td><td> </td></tr></table>";
<script type="text/javascript">
$(document).ready(function () {
var htmlcontentval = "<table border='1' cellpadding='0' cellspacing='0'><tr><td colspan='3'>Month-Year</td></tr><tr><td>Milestone</td> <td>Onsite Effort</td><td>Offshore Effort</td></tr><tr><td> </td><td> </td><td> </td></tr></table>";
$("textarea[title='Milestone
Information']").val(htmlcontentval);
});
</script>
});
</script>
Note: Milestone information is the title of the textarea used in
the Rich text field
Question 19: How to hide the Sharepoint Enhanced Richtext field?
Answer 19: $("textarea[title='richtexttitle']").closest("tr").hide();
Question 20: How to unhide the Sharepoint Enhanced Richtext field?
Answer 20: $("textarea[title='richtexttitle']").closest("tr").show();
Answer 19: $("textarea[title='richtexttitle']").closest("tr").hide();
Question 20: How to unhide the Sharepoint Enhanced Richtext field?
Answer 20: $("textarea[title='richtexttitle']").closest("tr").show();
Question 21: How to convert string to uppercase?
Answer 21: $("input[title='titlename']").val().toUpperCase();
Answer 21: $("input[title='titlename']").val().toUpperCase();
Question 22: How to check length of the string?
Answer 22 : $("input[title='titlename']").val().val().length;
Answer 22 : $("input[title='titlename']").val().val().length;
Question 23: How to validate Email address?
Answer 23:
Answer 23:
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var emailaddressVal = $("input[title='titlename']").val();
if(!emailReg.test(emailaddressVal))
{
alert("Please enter valid email address");
}
var emailaddressVal = $("input[title='titlename']").val();
if(!emailReg.test(emailaddressVal))
{
alert("Please enter valid email address");
}
Question 24: How to prevent free email addresses like yahoo.com,
gmail.com ?
Answer
24:
var emailblockReg = /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)([\w-]+\.)+[\w-]{2,4})?$/;
var emailaddressVal =
$("input[title='titlename']").val();
if(!emailblockReg.test(emailaddressVal))
{
alert("Free Email addresses are not allowed");
}
if(!emailblockReg.test(emailaddressVal))
{
alert("Free Email addresses are not allowed");
}
Question 25: How to get the lookup text value (Dropdown text
value)?
Answer 25: $("option:selected", $("select[title='titlename']")).text();
Answer 25: $("option:selected", $("select[title='titlename']")).text();
Monday, June 17, 2013
List and Library templates missing from SharePoint sites
Recently i came across an issue where users don't have default Library and list templates to choose from when they want to create a list or library.
Issue -
When user selects 'More options' from site actions menu and select filter by:
Library - It shows only three templates Asset, Slide and wiki page Library.
List - It shows only one template 'Import Spreadsheet'.
Solution -
Team collaboration Lists feature provides team collaboration capabilities for a site by making standard lists, such as document libraries and issues, available. so if you encounter such issue just make sure Team collaboration Lists feature is activated on the site.
Go to Site settings -> Manage site features -> find 'Team Collaboration Lists' feature -> Activate
Issue -
When user selects 'More options' from site actions menu and select filter by:
Library - It shows only three templates Asset, Slide and wiki page Library.
List - It shows only one template 'Import Spreadsheet'.
Solution -
Team collaboration Lists feature provides team collaboration capabilities for a site by making standard lists, such as document libraries and issues, available. so if you encounter such issue just make sure Team collaboration Lists feature is activated on the site.
Go to Site settings -> Manage site features -> find 'Team Collaboration Lists' feature -> Activate
Subscribe to:
Posts (Atom)