Report Builder 3.0 以 SharePoint 列表作为数据源,使用列表的相对 URL

发布于 2024-11-01 03:33:23 字数 774 浏览 4 评论 0原文

我正在使用 Report Builder 3.0 创建一个在 SharePoint 2010 中使用的报表。SQL Server 2008 R2 是 SharePoint 集成模式下 Reporting Services 的后端。 Report Builder 3.0 的一项很酷的功能是使用 SharePoint 列表作为数据源,其设置非常简单 - 只需将 SharePoint 列表的 URL 作为连接字符串提供给它即可。

我最终想将此网站打包为网站模板,包括其中的报告,这意味着 URL 需要是相对的而不是绝对的。例如,而不是这样:

http://mainsite/subsite1/lists/mylist

... 我需要指定这样的内容:

mylist

... 这样,当我将其打包为站点模板并基于该模板创建新站点时,报告将使用新站点的列表而不是指向原始站点的列表 URL。我已经尝试过“mylist”、“lists/mylist”等——除了指定 subsite1/lists/mylist 之外的所有内容——但到目前为止,除了完整的 URL 之外,没有任何效果。

是否可以使用相对 URL 或其他方法,以便每次基于此网站模板创建新网站时都不必在报告中手动更改连接字符串?

编辑:我误解了数据源的连接字符串中需要包含的内容。连接字符串中的不是列表的URL,而是站点的URL。不过,该问题的概念仍然有效 - 需要动态设置指向 SharePoint 列表的数据源的连接字符串。

I'm using Report Builder 3.0 to create a report for use in SharePoint 2010. SQL Server 2008 R2 is the back end with Reporting Services in SharePoint Integrated Mode. One of the cool features of Report Builder 3.0 is the use of a SharePoint List as a data source, the setup for which is very straightforward--just give it the URL for the SharePoint List as the connection string and it works.

I eventually want to package this site as a Site Template including the report that lives in it, which means that the URL will need to be relative instead of absolute. So for example instead of this:

http://mainsite/subsite1/lists/mylist

... I need to specify something like this:

mylist

... so that when I package this as a Site Template and create a new site based on that template, the report will work with the new site's list instead of pointing back to the original site's list URL. I've tried "mylist", "lists/mylist", etc.--everything short of specifying subsite1/lists/mylist--but nothing has worked so far except for the full URL.

Is it possible to use a relative URL or some other method so that the connection string won't have to be manually changed in the report every time I create a new site based on this site template?

Edit: I misunderstood what needed to go in the data source's connection string. It's not the URL to the list but rather the URL to the site that goes in the connection string. The concept of the question remains valid though--need to dynamically set the connection string of a data source that points to a SharePoint list.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心碎无痕… 2024-11-08 03:33:23

经过与一些同事的集思广益后,我们找到了答案。关键是使用连接字符串的表达式。使用我原来的示例,目标是获得以下内容:

http://mainsite/subsite1/

... 在连接字符串中,但无需对其进行硬编码 - 根据报告所在的位置使其动态化,以便可以将报告与网站的其余部分一起打包为网站模板。我最终得到的表达式是:

=Replace(Globals!ReportFolder, "Reports", "")

报告位于名为“Reports”的库中,因此 Globals!ReportFolder 返回:

http://mainsite/subsite1/Reports

Replace() 函数然后取出字符串的“Reports”部分,结果是连接字符串 I通缉。

需要注意的事项:

  • 在构建报告时无法测试表达式。我必须将站点 URL 硬编码到连接字符串中,以便设计人员在基于该数据源创建数据集时可以填充列表列表。否则,它不会显示可用列表,您必须手动输入所有内容。设计报告后,我将连接字符串更改为表达式,并且在部署时它起作用了。
  • 测试时,请确保刷新浏览器视图,而不是报告任务栏中的小刷新图标。似乎报告的内置刷新仅获取新数据,但使用现有的 rdl 文件,而刷新浏览器则强制它获取 rdl 的最新副本以及最新数据。这可能是不言自明的,但它给我带来了几分钟的困惑,因为我的设计更改看起来没有任何区别,所以希望这会帮助其他人不要经历同样的困惑。

After brainstorming with some co-workers we figured it out. The key is to use an expression for the connection string. Using my original example the goal is to get this:

http://mainsite/subsite1/

... in the connection string but without hardcoding it--make it dynamic based on where the report lives so the report can be packaged along with the rest of the site as a site template. The expression I ended up with is:

=Replace(Globals!ReportFolder, "Reports", "")

The report lives in a library called "Reports", so Globals!ReportFolder returns:

http://mainsite/subsite1/Reports

The Replace() function then takes out the "Reports" part of the string, and the result is the connection string I wanted.

Things to look out for:

  • You can't test the expression while you're building the report. I had to hardcode the site URL into the connection string so the designer could populate the list of lists when creating a dataset based on that data source. Otherwise it doesn't show the available lists and you have to manually type everything. After designing the report I changed the connection string to the expression, and when deployed it worked.
  • When testing make sure to refresh your browser view instead of the little refresh icon in the report's task bar. Seems like the report's built-in refresh only grabs new data but uses the rdl file it already has on hand, whereas refreshing the browser forces it to get the latest copy of the rdl as well as latest data. That's probably self-explanatory, but it caused me some confusion for a few minutes when it didn't look like my design changes made any difference, so hopefully this will help others not go through the same confusion.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文