Thursday, April 14, 2016

How to create a Web Application with Classic Authentication in SharePoint 2013

As we all SharePoint developer knows, Microsoft didn't provide a UI interface to create a Classic Authentication Web Application in SharePoint 2013.

But you can create a Classic Authentication Web Application by using powershell command, mostly this kind of practices are used during the migration of SharePoint from old version to SharePoint 2013.


==================
Powershell Command
==================

New-SPWebApplication -Name "SharePoint - 80" -ApplicationPool "SharePoint - 80" -ApplicationPoolAccount (Get-SPManagedAccount "Contoso\SPAdmin") -DatabaseName "WSS_Content" -Port 80 -URL http://myportal/


How to download a wsp file from Central Admin

You can easily download either one wsp file from central admin or you can download all wsp files by using powershell command in Sharepoint 2010 and 2013 environment.

============================
Download one wsp file
============================

$myFarm = Get-SPFarm
$myWSP = $myFarm.Solutions.Item("helloworld.wsp").SolutionFile
$myWSP.SaveAs("C:\helloworld.wsp")

============================
Download all wsp files
============================

$pathName = "c:\wspFiles\"

foreach ($solution in Get-SPSolution)
{
    $solid = $Solution.SolutionID
    $title = $Solution.Name
    $filename = $Solution.SolutionFile.Name
    $solution.SolutionFile.SaveAs("$pathName\$filename")
}

Useful Powershell Commands of SharePoint 2013

These are the following powershell commands which is commonly used during development, Farm Creation and for Administration:

===========================
Backup & Restore
===========================

Backup-SPSite -Identity http://ServerName:port -Path "c:\backup\file.bak"

Restore-SPSite -Identity http://Servername:port -Path "c:\backup\file.bak" -force

===========================
Add and Install WSP
===========================

Add-SPSolution c:\helloworld.wsp

Install-SPSolution –Identity helloworld.wsp -GACDeployment -force -WebApplication http://portal

===========================
Remove WSP
===========================

Remove-SPSolution -Identity helloworld.wsp

===========================
Update WSP
===========================

Update-SPSolution -Identity helloworld.wsp -LiteralPath C:\helloworld.wsp -GACDeployment

How to enable Ajax Functionality on Custom Master Page in SharePoint 2013

When you create a custom master page through design manager in SharePoint 2013, then unfortunately design manager does not add Ajax snippets in this page, and due to this you cannot apply Ajax functionality on your custom web part.

This is not a big deal now, you can just add below mentioned snippets in your custom master HTML page under a body tag and the same tag will be remove from Head.

<!--SPM:<asp:ScriptManager id="ScriptManager" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true"/>-->
<!--MS:<SharePoint:AjaxDelta id="DeltaSPWebPartManager" runat="server">-->
<!--MS:<WebPartPages:SPWebPartManager runat="server">-->
<!--ME:</WebPartPages:SPWebPartManager>-->
<!--ME:</SharePoint:AjaxDelta>-->

How you can change the name of SharePoint from Top Blue Bar

You can use powershell command to change or replace the name of SharePoint which is by default appear on top blue bar.

You can replace a "SharePoint" literal with these are the following options:
  • With Label
  • With Link
  • With Image & Link

===================================
With Label
===================================

Add-PSSnapin Microsoft.SharePoint.PowerShell

# get your site
$myApp = Get-SPWebApplication "http://mysite"

# add text
$myApp.SuiteBarBrandingElementHtml = '<div class="ms-core-brandingText">My Portal</div>'

# update
$myApp.Update()


===================================
With Link
===================================

Add-PSSnapin Microsoft.SharePoint.PowerShell

# get your site
$myApp = Get-SPWebApplication "http://mysite"

# add a linked text
$myApp.SuiteBarBrandingElementHtml = '<div class="ms-core-brandingText"><a style="color:#fff;" href="http://myportal">My Portal</a></div>'

# update
$myApp.Update()


===================================
With Image & Link
===================================

Add-PSSnapin Microsoft.SharePoint.PowerShell

# get your site
$myApp = Get-SPWebApplication "http://mysite"

# add an logo image
# $myApp.SuiteBarBrandingElementHtml = '<div class="ms-core-brandingText"><a href="http://myportal"><img src="/SiteCollectionImages/Logo.png"/></a></div>'

# update
$myApp.Update()


Thursday, March 29, 2012

How to manage Serial No. in form library in SharePoint

In SharePoint, form library is based on infopath form, when you submit the form in library, you have to required unique name or number. If you want that your form name is a sequence serial number then follow these steps.
  1. Add a field in your data source name as SNo.
  2. Create data connection to get Max value of ID from library, ID is a default value of any SharePoint library.
  3. Now add a rule of submit button and set field's value SNo = max(@ID) + 1.
  4. Remember, before set the value, you must retrieve the latest value of ID by using Query using a data connection.
  5. Here, one thing is very critical when you submit the form in library initially (means first time), you will get NaN value in ID. So, in this scenario, Point No. 3 will not work properly.
  6. To avoid this kind of issue, please follow the below steps.
  7. Open properties box of SNo. then goto Rules and Merge Tab.
  8. Then Add Rule, Set Condition and Set value.
    • Rule name can anything that you want.
    • Set Condition should be SNo = NaN.
    • Set Value should be SNo = 1.
  9. Now create data connection for submit the form and assign SNo in file name field.
  10. Good Luck guys :))) 

      Thursday, March 22, 2012

      How to clear infopath template cache

      Why we need to clear infopath template cache ?

      Basically sometime new changes in infopath template is not reflect on production environment after publishing the template, the reason is infopath cache. Your new template has successfully published on server machine, so don't need to worry about that. You need to remove / clear infopath cache from user machine(s) only.

      Just open RUN and type infopath/cache clearall then press OK button.

      Now you can open your infopath form and can see new changes in it.