Tuesday, August 23, 2016

Set SSRS Report Data Source Programmatically

Set SSRS Report Data Source Programmatically


 This script is designed for SSRS 2008 R2 and 2012 in SharePoint 2010/2013 Integrated mode, it will require tweaking for native mode or previous versions. 

This script will accept a SharePoint Document Library url and set the DataSource url for all the reports in that library.


#------------------------------------------------------------------------------------------- 
# Name:            Set-SSRSDataSourceInfo 
# Description:     This script will set the data source url for all reports in a doclib 
# Usage:        Run the function with the DocLibUrl,DataSourceName and DataSourceURL parameters 
# By:             Ivan Josipovic, softlanding.ca 
#------------------------------------------------------------------------------------------- 
Function Set-SSRSDataSourceInfo ($DocLibUrl,$DataSourceName,$DataSourceURL){ 
$DocLibUrl = $DocLibUrl.Replace("%20"," ").tolower(); 
if ($docliburl.EndsWith("/")){  
    $docliburl = $docliburl.Substring(0,$docliburl.length-1); 
} 
$webfound = $false$weburl = $DocLibUrl; 
 
while ($webfound -eq $false) { 
    if ($weburl.Contains("/")){ 
        $weburl = $weburl.Substring(0,$weburl.LastIndexOf("/")); 
        $web = get-spweb -identity $weburl -ea 0; 
        if ($web -ne $null){ 
            $webfound = $true; 
        } 
    }else{ 
        Write-Output -ForegroundColor Red "The Web could not be found"; 
        return -1; 
    } 
} 
$doclib = $web.lists |where {$_.RootFolder.Name.tolower() -eq $docliburl.Substring($docliburl.LastIndexOf("/")+1,$docliburl.length-$docliburl.LastIndexOf("/")-1)}; 
if($doclib -eq $null){ 
Write-Output -ForegroundColor Red "The DocLib could not be found"return; 
} 
$reports = $doclib.items | where {$_.File.Name.tolower().Contains(".rdl")} 
 
$SSRSurl = "$($web.url)/_vti_bin/ReportServer/ReportService2010.asmx"$SSRS = New-WebServiceProxy -uri $SSRSurl -UseDefaultCredential; 
foreach ($report in $reports){ 
    write-output "$($web.url)/$($report.url)"; 
    $dataSources = $ssrs.GetItemDataSources("$($web.url)/$($report.url)"); 
    if ($datasources.count -gt 0){ 
        for ($i = 0; $i -lt $dataSources.count; $i++) { 
            if ($DataSources[$i].name -eq $DataSourceName){ 
                write-output "Updating $($DataSources[$i].name)"; 
                $proxyNamespace = $DataSources[$i].GetType().Namespace; 
                $DataSources[$i].Item = New-Object ("$proxyNamespace.DataSourceReference"); 
                $DataSources[$i].Item.Reference = $DataSourceURL; 
                $SSRS.SetItemDataSources("$($web.url)/$($report.url)"$DataSources[$i]) 
                write-output "Done"; 
            } 
        } 
    } 
    write-output ""; 
 
} 
} 
 
Set-SSRSDataSourceInfo -DocLibUrl "http://test.com/site/reports/Documents" -DataSourceName "BIRepository" -DataSourceURL "http://test.com/site/reports/Data Sources/BIRepository.rsds" 
Set-SSRSDataSourceInfo -DocLibUrl "http://test.com/site/reports/Documents" -DataSourceName "BIOlapStore" -DataSourceURL "http://test.com/site/reports/Data Sources/BIOlapStore.rsds"
That it!

 Hope this help,
Oumaima

Friday, July 22, 2016

Post Back does not work after writing files to response

Post Back does not work after writing files to response


Problem:
I have a button on the page that sends a file and after clicking the button, the rest of the form was unresponsive. Turns out it is a sharepoint thing that sets the variable _spFormOnSubmitCalled to true to prevent any further submits. When we send a file this doesn't refresh the page so we need to manually set this variable back to false.
Solution:
On your button in the webpart set the OnClientClick to a function in your javascript for the page.
 <asp:Button ID="generateExcel" runat="server" Text="Export Excel" 
OnClick="generateExcel_Click" CssClass="rptSubmitButton"
OnClientClick="javascript:setFormSubmitToFalse()" />
Then in the javascript I have this function.
function setFormSubmitToFalse() {
    setTimeout(function () { _spFormOnSubmitCalled = false; }, 3000);
    return true;
}
The 3 second pause I found was necessary because otherwise I was setting the variable before sharepoint set it. This way I let sharepoint set it normally then I set it back to false right after.

Hope this help,
Oumaima

Tuesday, June 7, 2016

SHAREPOINT 2013 POWERPIVOT MANAGEMENT DASHBOARD EMPTY

SHAREPOINT 2013 POWERPIVOT MANAGEMENT DASHBOARD EMPTY

When you install the SharePoint BI stack, you need to create a PowerPivot Service application that will manage the PowerPivot workbooks via a very nice dashboard which unfortunately was empty in my Central Admin. no error, nothing in the ULS, just an empty page.
To fix that, I activated the PowerPivot Administration feature in Central Administration :
image
That it!!
Hope this help,
Oumaima Achkari

Thursday, June 2, 2016

Advantages and disadvantages of separate content database on site collection level

Advantages and disadvantages of separate content database on site collection level

Hi,

what are the advantages of having a unique content database per sharepoint sites collection? How about disadvantages? How will it impact the server's performance?

This article will answer all these questions, here we go :)

Here are 3 reasons to separating site collection into different content databases:
  1. One or more of the site collections is close to 200GB and will grow to beyond that size. Separating it will make you life simpler for backups and restores and future upgrades to the next version of SharePoint.
    Also if you need to restore data from one site collection and it happens to be in its own content database you can restore it without affecting your other sites.
  2. To separate like content into their own content databases, ie keep MySite personal sites in a different content db from Team sites.
  3. To separate content for legal / business reasons. You probably do not want to have all the legal sites in the same db.

Disadvantages  - if you were going to put all your site collections into their own content database (30) and you then need to create a new site collection, and you want that in its own DB too, you would need to first take all the existing dbs offline (users can still access the the db read/write) and set the create new db on site collection count limit to one, before you create the new site collection. (I had publish a topic about this stuff :http://oumaimasharepoint.blogspot.com/2016/06/unique-content-database-per-sharepoint.html)

If you create a site collection using the GUI, you cannot select the Content Database that the site collection gets created in.
This is why you have to take them "offline". Offline doesn't mean they are not accessible, but there cannot be created any more site collections in this Content database.
Another way to do it without having to take offline all other content databases is by using PowerShell.
To create a site collection using PowerShell, you can use the "New-SPSite" Cmdlet.
To create a site collection using PowerShell in a specific Content Database, it would be something like this:
New-SPSite -Url Http://yoururl.com/sites/newsitecollection -OwnerAlias "domain\sitecollectionadmin" -ContentDatabase "Name of ContentDatabase" -Name "My New Site Collection" -Description "Optional description" -Language "1033 (for english, optional)"

Hope this help,
Oumaima

Unique Content Database per SharePoint Site Collection

Unique Content Database per SharePoint Site Collection

It’s a question that comes up in every deployment of SharePoint: Should I have many site collections or one site collection with many sub sites?  My definitive answer: “It depends”.  
This post isn’t to address that however.  Let’s assume you decided on many site collections.  Which will bring you to another question you’ll ask yourself.  Should I have one content database for all of the site collections, or one content database for each site collection?  My definitive answer: “It depends”.
This post isn’t to address that either.  Let’s assume that you decided on one content database per site collection.  Or, let’s assume that you are going to create a new site collection and you want it to have its own content database.  Now that, we are going to address.
So how to in SharePoint?  Well, it’s not exactly intuitive, but none-the-less we can do it.

In Central Administration, you need to examine the current Content Database situation for your application.  Browse to content databases at: Central Administration > Application Management > SharePoint Web Application Management
In our example, we only have one Content Database (WSS_Content_Clients) with 1 site collection in it.
image
First, let’s create a new content database.  So, click on ‘Add a content database’ and go through the steps.  I recommend naming the content database the name of the site collection.  In our example, I called it WSS_Content_NEWSITECOLLECTION.
image
Now if we look at our content databases for our web application, you’ll see that we have two.  And WSS_Content_NEWSITECOLLECTION has zero site collections in it.
image
So what will happen if we create a new site collection in this Web Application?  When creating a new site collection in Central Admin there isn’t a means to select which content database to use.  Or is there?… Umm hmm.
Edit WSS_Content_Clients database (the database you don’t want to have the new site collection), and set it’s status to ‘Offline’.  Don’t worry, the database isn’t offline in typical sense.  It just means that new site collections can’t be created in it.  (This is just a bad name all together, but oh well).
image
Now if we look at our content databases, we’ll see that only our WSS_Content_NEWSITECOLLECTION is available for new site collections.
image
You’re all set now.  Go and create yourself a new site collection, and it will automatically create itself in our new content database, WSS_Content_NEWSITECOLLECTION.  Afterwards, you can stop it by setting it to offline as well to prevent other site collections being created in it.
image
There are other ways to achieve what we just did, but this one works for me.  Old habits are hard to break I guess.
Now, the next question that you’ll most likely end up asking is: How on earth am I going to figure out which site collection goes with what content database from a management standpoint?  Naming conventions don’t carry us but so far do they?
No worries there either, head over to your list of site collections for you application at: 
Central Administration > Application Management > Site Collection List
Select the site collection, and it will tell you what Content Database it is using.
image



Tuesday, May 31, 2016

Configuring the SharePoint 2013 Managed Metadata service for Navigation

Configuring the SharePoint 2013 Managed Metadata service for Navigation

One of the new features of SharePoint 2013 is the ability to save your custom navigation in the Managed Metadata Service Application. Some of my coworkers were playing with it and noticed it worked fine on farms set up with the Farm Configuration Wizard (Booooo!) but did not work on Farms where the service applications had been lovingly created by hand. With some help we were able to find the difference and fix it. I would tell you how now, but I’m building up for the big reveal at the end. Big reveals are the hallmark of great storytelling.
We found the problem when going to a site collection with the Publishing Feature enabled and going to Site Settings > Navigation. We tried to enable the Managed Navigation, which stores our custom navigation links in the Managed Metadata service. Here’s what the problem looked like:
Office-PC 8-8-2012 10.11.05 PM -2
We checked the two boxes to enable Managed Navigation. Since we were turning it on for the first time we didn’t have a term set created to store our navigation in. Clicking the “Create Term Set” button on the bottom resulted in the following error:
Failed to create term set. A default managed metadata service connection hasn’t been specified.
This message made it sound like the service application wasn’t created (it was) or that it wasn’t in this web application’s proxy group (it was), but that wasn’t the case. We discovered there’s a magic checkbox in the Proxy for the Managed Metadata Service application that makes it available for navigation. The Farm Configuration Wizard checks that checkbox. I hadn’t. Here’s how to do it. Go into Central Admin > Manage Service Applications and highlight the Managed Metadata Service Proxy. Then click Properties in the Ribbon.
Office-PC 8-8-2012 10.12.25 PM -2
In the Properties for the Proxy, check the box next to “This service application is the default storage location for column specific term sets.”
Office-PC 8-8-2012 10.12.56 PM
If you’d prefer to do it with PowerShell (and honestly why wouldn’t you?) you can do it like this:
Office-PC 8-9-2012 9.05.41 AM
and for your copying and pasting pleasure:
$saproxy = Get-SPServiceApplicationProxy | Where-Object { $_.typename -like "Managed*" }
$saproxy.Properties.IsDefaultSiteCollectionTaxonomy
False
$saproxy.Properties.IsDefaultSiteCollectionTaxonomy = $true
$saproxy.Update()
Regardless of how you change that setting, either through PowerShell or the wimpy way through Central Admin, you should be able to create a Term Set when enabling Managed Navigation. Victory looks something like this:
Office-PC 8-8-2012 10.23.24 PM -2
Hope this help,


Monday, May 16, 2016

How to remove delegate control rights in AD

How to remove delegate control rights in AD

Hi

Question:
I have added a user on the Delegate Controls wizard but now I want to remove it, how do I do this?
Solution :
on the OU open the properties and then go to security tab, here the user account should be listed and can be removed.

Hope this help,
Oumaima