Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with DataSource #45

Open
joemorin73 opened this issue Sep 20, 2018 · 0 comments
Open

Issue with DataSource #45

joemorin73 opened this issue Sep 20, 2018 · 0 comments

Comments

@joemorin73
Copy link

There appears to be some issues when updating Shared Datasources in the Reports:

    <DataSource Name="PRODSQL">
      <DataSourceReference>PRODSQLSRC</DataSourceReference>
      <rd:SecurityType>None</rd:SecurityType>
      <rd:DataSourceID>d8e06de5-dc11-494d-9d11-a6d29ccb30c8</rd:DataSourceID>
    </DataSource>
  </DataSources>
Foreach($serverDataSource in $serverDataSources){
    if([System.String]::Compare($serverDataSource.Name.Trim(),$reportDataSourceName.Trim(),$true) -eq 0){
        $dataSourcePathNew = $serverDataSource.Path;
        
        Write-Host "Updating DataSource '$reportDataSourceName' to path '$dataSourcePathNew'..." -NoNewline;
            
        $dataSourceReferenceNew = New-Object("$type.DataSourceReference");
        $dataSourceReferenceNew.Reference = $dataSourcePathNew;

        $dataSourceNew = New-Object ("$type.DataSource");
        $dataSourceNew.Name =$reportDataSourceName;
        $dataSourceNew.Item = $dataSourceReferenceNew;
        #[System.Collections.Generic.List[$type + ".DataSource"]]$arr = @($dataSourceNew);
        $ssrs.SetItemDataSources($report.Path,$dataSourceNew);
        Write-Host "Done!";
        break;
    }
}

In the if Statement, $reportDataSourceName is being compared to the DataSource names. This won't work if the reports DataSource name is different than the shared DataSource's name. (Example, If is looking for PRODSQL, but only PRODSQLSRC exists. It will never be found.)

$reportDataSourceName = $_.Name should be changed to $reportDataSourceName = $_.DataSourceReference.

Additional minor point, I'm not sure if it would be needed, but you may need to strip any path to the reference. (If it exists.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant