Showing posts with label Sharepoint 2010. Show all posts
Showing posts with label Sharepoint 2010. Show all posts

Saturday, July 5, 2014

PowerShell Commands: Download files/documents from SharePoint document libraries

In SharePoint 2013 we have an option to sync all the data from SharePoint document libraries to local folders by using Shared drive concept. We can download the document s from SharePoint document library using Power Shell commands also. We can do that in overall site collections and all the site collection may contain loads of documents and downloading one by one is a huge task by using windows explorer.

To download the document we can use following script,

$listUrls="Doc lib 1 URL″,” Doc lib 2 URL ″,” Doc lib 3 URL ″," Doc lib 4 URL ″ (All the document libraries URL’s)
#Enter the web site URL

$web = Get-SPWeb -Identity $webUrl

#Load all the list URLs in the web, Open the list URL.

foreach($listUrl in $listUrls)
{

#get the list URL

$list = $web.GetList($webUrl+”/”+$listUrl)

function DownloadDocuments{
    param($folderUrl)
    $folder = $web.GetFolder($folderUrl)
    foreach ($file in $folder.Files) {

       
#Ensure destination directory

        $destinationfolder = $destination + “/” + $folder.Url
        if (!(Test-Path -path $destinationfolder))
        {
            $dest = New-Item $destinationfolder -type directory
        }

       
#Download file

        $binary = $file.OpenBinary()
        $stream = New-Object System.IO.FileStream($destinationfolder + “/” + $file.Name)
        $writer = New-Object System.IO.BinaryWriter($stream)
        $writer.write($binary)
        $writer.Close()
        }
}

#Download root folder documents

DownloadDocuments ($list.RootFolder.Url)
foreach ($folder in $list.Folders) {

#download all the documents in each sub folders

   DownloadDocuments($folder.Url)
}


Sunday, June 15, 2014

Multi domains in SharePoint 2010 people picker

In SharePoint environment people picker is one of the main part in the farm to provide the users available from all the domains to select the users. By configuring stsadm commands we can grab the users from different domains.
SharePoint will use Application pool identity to search users in active directory. If application pool account is not having permissions to do that, we have to encrypt the password.

To do that we can use following command in STSADM,

stsadm -o setapppassword -password  password

We have to set the domains should be searched on WFE for each web application,

stsadm -o setproperty -pn peoplepicker-searchadforests –pv domain:domain1;domain:domain2,domain2\account,password -url WebApplication
 
Hope this helps.



Saturday, June 14, 2014

SPGridView error: Value cannot be null. Parameter name:propName

While working with SharePoint grid view to show data, I got an error saying that “Value cannot be null. Parameter name:prop name as shown the image below.



I have checked the properties assigned to SPGridview. By default SPGrid will have option to group the result based on a column. By setting AllowGrouping is “true” we can group the data. We have to specify the grouping column name, Group collapse and Group field display name as shown the code below.

SPGridView.AllowGrouping=true;
SpGridView. GroupField=”Group Field Name”;
SPGridView.AllowGroupCollapse = false;
SPGridView.GroupDescriptionField = “Group Description Name”;
SPGridView.GroupFieldDisplayName = “DisplayName Text

We have to set GroupField, AllGroupCollapse, GroupDescriptionField and GroupFieldDisplayName along with AllwGrouping field to fix the error.

Wednesday, June 4, 2014

SPGrid Error in SharePoint 2010: System.ArgumentNullException: Value cannot be null. Parameter name: container

While working with SharePoint 2010 Grid view grouping depending on dropdown value, got an error saying that “Value cannot be null. Parameter name: Container” as shown the image below.
















Iam unable to find the issue while debugging the code. I have spent much time on this issue finally got the reason. By making “EnableViewState” to false error got fixed as show the code below.

grdPropertyValues.EnableViewState = false;
grdPropertyValues.AllowSorting = true;
grdPropertyValues.AllowGrouping = true;
grdPropertyValues.AllowGroupCollapse = true;



Here grdPropertyValues is SPGridview object. Hope this helps.

Saturday, May 17, 2014

SharePoint 2010 installation Error – Could not create Configuration database

While installing SharePoint, I got an error saying that “Could not create Configuration database - Failed to call GetTypes on assembly Microsoft.Office.InfoPath.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c The system cannot find the file specified. Could not load file or assembly 'Microsoft.Office.InfoPath, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies.

I have rechecked pre-requisites and re-installed all the pre-requisites. But still Iam facing the same issue. By checking the issue in deep I have found that issue is related to InfoPath. In my machine Iam having InfoPath 2013. It’s blocking SharePoint Configuration wizard to create database.

To fix this issue we have to uninstall InfoPath from current machine. After uninstalling the InfoPath Configuration wizard ran successfully.

Hope this helps.

Friday, May 16, 2014

SharePoint – Back to Basics – SharePoint URL field link open in new window using JavaScript

One my project I got a requirement that in SharePoint URL field we have to open the link in new window. But URL field, we don't have option to open the link in new window through UI. For that I have added custom JavaScript in Content editor web part/Script web part.

Before updating JavaScript we have to add #Opennewtab at the end of the URL in URL field as Show the image below.



Add following JavaScript to the List items page through Content Editor web part/ Script editor web part.

<script language="JavaScript">
_spBodyOnLoadFunctionNames.push("UpdateLinks");
function UpdateLinks() {
var anchorsTags = document.getElementsByTagName("a");
for (var x=0; x< anchorsTags.length; x++) {
if (anchors[x].outerHTML.indexOf('#Opennewtab)>0)
{
                oldText = anchors[x].outerHTML;
                newText = oldText.replace(/#Opennewtab/,'" target="_blank');
                anchors[x].outerHTML = newText;
}
}
}
</script>

After adding this script save and close the web part. All the links added with #OpeninNewtab will be open in new window.