Thursday 19 December 2013

Backup and Restore SharePoint 2010 Site Collection with PowerShell 

A PowerShell command prompt will appear and you need to format the following to fit the backup for your site.

Backup-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]
  • Force – Include this if you want to override a backup with the same name
  • NoSiteLock – Will prevent the site from going to Read Only mode while the backup is being taken.  A small warning, if someone changes content on the site while the backup is being created and according to Microsoft “might lead to possible data corruption”
  • UseSQLSnapshot – A database snapshot will be taken before the backup begins and the backup will be done off the snapshot. The advantage is that changes can be made to the site while the backup process is running without fear of corruption.  The snapshot will be deleted automatically when the backup is completed.  You don’t need to specify the -NoSiteLock parameter when using this method
For Example:
Backup-SPSite -Identity http://servername/sites/BISite -Path D:\SharePointBackups\BISite\07-13-2011.bak

Restore-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-DatabaseServer DatabaseServerNameHere] [-DatabaseName ContentDatabaseNameHere] [-HostHeader HostHeaderHere] [-Force] [-GradualDelete] [-Verbose]

  • DatabaseServer – Specify the server for the content database
  • DatabaseName – Specify the name of the content database
  • HostHeader – URL of the Web application that will hold the host-named site collection
  • Force – Overwrite the site collection if it exists
  • GradualDelete – Recommended for site collections over 1 Gig in size, existing data is marked as deleted and gradually removed over time by a job rather than all at once to reduce the performance hit of deleting large amounts of data

Thursday 3 October 2013

SPServices GetUserProfileByName Jquery With Parameters AccountName

SPServices GetUserProfileByName JQuery

Requirement:- Hide the user according to there permission level means if the user have permission in particular group A then one field "SPS-DistinguishedName" have entry like "OU=ServiceAccounts".
                          I tried to call the function getUserProfileByName with a specified username/AccountName using jquery with SPServices for hide the user form details.
<script src="/teams/tsc/rintu/CSS/jquery.min.js"></script>
<script src="/teams/tsc/rintu/InfoPath/Shared%20Documents/jquery.SPServices-0.7.2.js"></script>

<script type="text/javaScript">
$(document).ready(function()
{
$('.ms-spbTree').each(function(){

$(this).find('li').each(function(){
var obj=$(this).attr('id');
var details=getTheUserInfo(obj);
if(details.indexOf("OU=ServiceAccounts")>-1)
{
$(this).hide();
}

});
});
});

function getTheUserInfo(acct){
var ph;
$().SPServices({
operation: 'GetUserProfileByName',
async: false,
accountName: acct,
completefunc: function(xData, Status) {
ph=$(xData.responseXML).find("PropertyData").find("Name[text=SPS-DistinguishedName]").parent().find("Values").text();
}
});
return ph;
}
</script>

Friday 13 September 2013

Change login name in SharePoint

Change default welcome control in SharePoint master page

Default welcome login control ( domain\your name)  change to "Welcome, first name last name" in SharePoint master page.

Add the below code in the master page:-


Tuesday 20 August 2013

Hide the Column header in List View Web Part in SharePoint

Using CSS, Hide the Column header in List View Web Part

Add a Content Editor Web part  on the Page. Add following HTML under Source Editor :
style>
.ms-viewheadertr { display: none;}
/style>
Also, set Layout as "Hidden" for Content Editor.
This will hide the column  headers.

Tuesday 13 August 2013

SharePoint Discussion Board Customization with Data View Web Part

User want to customization in SharePoint Discussion Board using SharePoint Designer like the below image:-
For that you should maintain two column: -
      -- Name: [like-Test_01] with Hyperlink the item.
      -- Limited Body: [like-Test by Rintu Mondal].
      -- Add Comment : For add the new comment in discussion board.

Following are the steps for creating the discussion board:-
1. Add one Empty Data View Web Part in a page.
2. Select data source with two column (Name and Limited Body).
3. Change code just
     
 Add Comment for herf= "../../..{@FileDirRef}/NewForm.aspx?Source={@FileRef}&ContentTypeId=0x0107&amp;DiscussionParentID={@ID}"

4. save ok

Wednesday 7 August 2013

Delete SharePoint Custom Group Using PowerShell

Delete SharePoint Custom Group Using Power Sell Scirpt

Deleted SharePoint custom group names are fetching from Excel sheet.
 - In Excel shell there is one column name is "Name".
Following is the power shell script code:
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$count = 0
$contentWebAppServices = (Get-SPFarm).services |? {$_.typename -eq "Microsoft SharePoint Foundation Web Application"}
foreach($webApp in $contentWebAppServices.WebApplications)
{
    write-host "Site Collections"
    write-host ""
    foreach ($site in $webApp.Sites) 
    {
        $count++
        write-host "Site Collections URL --> -->" $site.URL
           write-host ""
           write-host "SubSites"
           write-host ""
          
           if($site.AllWebs -ne 'null')
           {
              foreach ($web in $site.AllWebs)
            {
                $count++
                write-host "SubSite URL --> --> -->" $web.URL
                write-host ""

      
               $spGroups = $Web.SiteGroups
               for ($index = 0; $index -lt $spGroups.Count; $index++)
               {
                write-Host "groupname" $spGroups[$index].Name
                $SharePointGroupName= import-csv "C:\Users\test1\Desktop\PowerShell Script\SharePointListName.csv"
                        $SharePointGroupName|ForEach-Object{
                                $groupname=$_.'NAME'
                if ($spGroups[$index].Name -eq $groupname )
                {
                     $spGroups.Remove($groupname)
                           Write-Host $groupname
                             $spweb.Update();
                        }
                   }
               }
            }
        }
    }
}
write-host "Total Count :" $count


Delete SharePoint List Using Powershell

Delete SharePoint List using Power shell Script

Deleted SharePoint list names are fetching from Excel sheet.
 - In Excel shell there is one column name is "Name".

 Following is the power shell script code

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$count = 0
$contentWebAppServices = (Get-SPFarm).services |? {$_.typename -eq "Microsoft SharePoint Foundation Web Application"}
foreach($webApp in $contentWebAppServices.WebApplications)
{
    write-host "Site Collections"
    write-host ""
    foreach ($site in $webApp.Sites)
    {
       $count++
       write-host "Site Collections URL --> -->" $site.URL
       write-host ""
       write-host "SubSites"
       write-host ""
       if($site.AllWebs -ne 'null')
       {
     foreach ($web in $site.AllWebs)
       {
           $count++
       write-host "SubSite URL --> --> -->" $web.URL
       write-host ""
       $lists = $web.Lists
           for ($index = 0; $index -lt $lists.Count; $index++)
       {
               $SharePointListName= import-csv "C:\Users\test1\Desktop\PowerShell Script\SharePointListName.csv"
               $SharePointListName|ForEach-Object{
               $ListName=$_.'NAME'
               if ($lists[$index].Title -eq $ListName)
               {
                    $lists[$index].Delete()
                    Write-Host "Web = $web, List = $ListName "
                    $web.Update();
               }
           }
     }
       }
    }
}
}

write-host "Total Count :" $count


 

 




Sunday 14 April 2013

Redirect Infopath Webpart to Custom URl after Submit the Form


This is the solution to recirect the Infopath webpart to custom URl, after submit the form.

Step1: Create a page and add Infopath Webpart.
Step2: Refer the Infopath Form in Infopath Webpart.
Step3: Add a content Editor Webpart to the Infopath webpart page and add below code.

script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"
/script

script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"
/script
script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js" type="text/javascript"
/script
script type="text/javascript"
( function($)
{
$(document).ready(
function()
{
if($('#DialogFinalMessage').children().length>0)
{
window.location.href = "custom url";
}
}
);
} ) ( jQuery );
/script

Wednesday 27 March 2013

Display Icon in the Library column in SharePoint 2010

Just like that :-
Following are the Steps:-
1. Go to SharePoint Library, create one column "Status" name with three dropdow values:-
     -Green
     -Red
     -Yellow
2. Create another column, Calculated (calculation based on other columns) and some code in formula.


Code Example:-
=IF(Status="Green","image url",IF(Status="Red","image url",IF(Status="Yellow","image url")))

Set HyperLink URL and Description in SharePoint Library/List columns using Nintex Workflow 2010

Just Like:-
Following are the Steps to set the hyperlink url and description in the SharePoint using Nintex workflow 2010:-
1. Create Nintex workflow, take one "SET FIELD VALUE" control.
2. Configure the set field value control

Format: HyperLink URL then "," and then " "space

Example: we are using (www.google.com, google)  then it shows only google in fornt end and www.google.com back end .

Monday 18 March 2013

Print Feature in the InfoPath in SharePoint Library

Problem: - User wants to print the InfoPath Form through browser in the SharePoint.
For example, user has created one list or library and opened the document including all data for print purpose without cuts off any data.

Solution: - Out of the box InfoPath print functionality is only present in SharePoint Library not in SharePoint List. For list we need some customization in the InfoPath code behind.

Example with SharePoint Library:-
According to user requirement, take one form library for print functionality. Following are the steps to configure the “Print Functionality”.
1. Take one InfoPath Form with two views, “Main View” for entering all the data and “Print View” for only displaying all the data.

2. Main view is very simple to create by just drag-drop the controls but Print view takes “Calculated Value” control for binding the existing fields like textbox, rich text box etc. in print view.

3. InfoPath under File > Info > Form Options you have several possibilities to restrict users from doing stuff with your form. To get the print functionality you need to enable the InfoPath Ribbon ("Show InfoPath commands in Ribbon or toolbar" and also the Print Preview option”)

4. Publish the InfoPath Form in SharePoint Library, then open the items and click the “print view” in the top menu bar.















Saturday 9 March 2013

"Alert Me" Feature Configuration in SharePoint

Problem: - User wants to see all the items which are Added or Updated within a day in the SharePoint list or library. Just one example, one user has an owner of the SharePoint site. He creates one list (name Employee Details) and he want know how many items are added or updated in a day. He wants all the data in the form of email at the end of the day (just like Employee Details- Daily Summary).



Solution: - It is possible in many ways like in Nintex workflow, SharePoint Designer workflow but most simple way is using Out of box “Alert feature”. It is very simple or everyone who has permission can able to configure the alert feature in the list or library in the SharePoint.

Following are the steps of configuration the “Alert” feature in the SharePoint:-
1. Log into SharePoint site.
2. Go to list or library where you want to configure the alert feature then click on “Alert Me” tab in list tools.

3.Then configure according to conditions:- - User wants to see all the items which are Added or Updated within a day in the SharePoint list.


Tuesday 12 February 2013

Insert dynamic table in email body using nintex workflow 2010

 

 Following are the steps:-
1. At first take one "Query List" ,  query all the data according to sort function and store it in collection Var.
2. then take one "For Each" configuation it.
3. then take one "Set Variable" for storing the current item value (Like varProject_name=Project Name).
4. then take one "Build String" configuration it. like..
      <#tr><#td>varProject_name<#/td><#/tr>{workflow:MailBody}
      -MailBody is multiple line textbox.
5. After completed the For Each loop, then Add one "Build String" control.
      <#table><#tr><#td>Project Name<#/td><#/tr>{workflow:MailBody}   <#/table>
6. then take one "Send Notification" control, add in email body {workflow:MailBody}.
7. Save and Publish it.






Thursday 31 January 2013

Character Limit in RichText Box in Infopath 2010 with SharePoint 2010

How to limited character  enter in Rich Textbox in InfoPath 2010 with SharePoint 2010.

1. At first take one rich text box in Infopath 2010.
2. Add Rule in  Rich Textbox, then select "Validation". Rule type=Validation
3. Set a condition,
      The expression= string-length(.)>10
4.Insert screen tip: "Character Limit to 10"
5.Ok

Wednesday 2 January 2013

How to configure SharePoint Solution Packages WSP (web solution package)

Following Steps:-


Step 1: Retract Solution (if solution packages is already developed in server).

stsadm -o retractsolution -name example.wsp -url http://server-name/sites/site-name -immediate

Step 2: Delete Solution (if solution packages is already developed in server).

stsadm -o deletesolution -name example.wsp

Step 3: Add the solution.

stsadm -o addsolution -filename E:example.wsp

Step 4: Deploy the solution.

stsadm -o deploysolution -name example.wsp -url http://server-name:port/sites/site-name/ -immediate -allowCasPolicies

Step 5: Go to Site Collection features and select the wep part for (Active or Deactive).

Convert list or library sharepoint data into excel sheet using JavaScript.

Following Steps:-
1-Take one content editor web part,
2-Put below code with all details.


'input class="ms-rteThemeBackColor-5-4" onclick="location.href='/site/site-name/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=list-name;View=view-name; CacheControl=1'" type="button" value="Export to Excel"/ /'

In Simple:-
{siteurl}/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List={GUID of list}&View={GUID of view}&CacheControl=1