2

I am trying to connect a custom webpart (provider) to a ReportViewerWebPart (consumer) programmatically, using a Powershell script.

I get the error message below when I execute the following line:

$wpConnection = $webpartmanager.SPConnectWebParts($wpProvider, $providerConnectionPoint, $wpConsumer, $consumerConnectionPoint, $transformer)

Error message:

Microsoft.SharePoint.WebPartPages.WebPartPageUserException: The transformer type "Microsoft.SharePoint.WebPartPages.TransformableFilterValuesToFilterValuesTransformer" is not allowed to be used on this page.

Does anyone know what may be causing the error and how to fix it? Similar code works when I run it as a Visual Studio application.

1

You might want to try the following:

$web = Get-SPWeb ($siteurl) 
$list = $web.Lists["Web Part Gallery"] 
$wpManager = $web.GetLimitedWebPartManager($web.Url + "pages/pagename.aspx",[System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared); 
$wpl = $list.Items | where {$_.Title -eq "Your Webpart Name"} 
$xmlReader = New-Object System.Xml.XmlTextReader($wpl.File.OpenBinaryStream()); 
$errorMsg = "" 
$webPart = $wpManager.ImportWebPart($xmlReader, [ref]$errorMsg) 
$wpManager.AddWebPart($webpart,"Header",1) 
$wp2 = $wpManager.WebParts | Where {$_.Title -eq "LeftMarginFilterWebPart"} 
$conWP = $wpManager.GetConsumerConnectionPoints($webpart)[0] 
$provWP = $wpManager.GetProviderConnectionPoints($wp2)[0] 
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") 
#if these are ootb web parts you need to set the trans up and call the overloaded SPConnectWebParts with $trans as the last param 
#$trans = New-Object Microsoft.SharePoint.WebPartPages.SPRowToParametersTransformer 
#trans.ConsumerFieldNames = new string[] {"Category"}; 
#trans.ProviderFieldNames = new string[] {"Title"}; 
$newCon = $wpManager.SPConnectWebParts($wp2,$provWP,$webPart,$conWP) 
$wpManager.SPWebPartConnections.Add($newCon); 
$wpManager.Dispose() 
$web.Dispose()

Original Post: http://xopherdesign.com/SitePages/Posts.aspx?PID=5

  • 1
    Thank you @Supermode for the response. I have tried your code with few modifications but ran into an error: The provider connection point "Parameter Value" on "Page" and the transformer do not use the same connection interface. – JensPM Jun 20 '14 at 15:20
  • 1
    My Provider web part has interface type: Microsoft.SharePoint.WebPartPages.ITransformableFilterValues <br/>And the Consumer web part (Microsoft.ReportingServices.SharePoint.UI.WebParts.ReportViewerWebPart) is of InterfaceType : Microsoft.SharePoint.WebPartPages.IFilterValues – JensPM Jun 20 '14 at 15:26
  • @jensPM. I am facing the same issue. Did you get to resolve the issue. If yes, can you please help me out with this.. – Rohit Waghela Nov 30 '18 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.