惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
爱范儿
爱范儿
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss
B
Blog RSS Feed
博客园 - 聂微东
G
GRAHAM CLULEY
Engineering at Meta
Engineering at Meta
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
WordPress大学
WordPress大学
Scott Helme
Scott Helme
AI
AI
S
Security Affairs
T
Threat Research - Cisco Blogs
M
MIT News - Artificial intelligence
T
Troy Hunt's Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
AWS News Blog
AWS News Blog
T
Threatpost
Cyberwarzone
Cyberwarzone
www.infosecurity-magazine.com
www.infosecurity-magazine.com
U
Unit 42
V
Vulnerabilities – Threatpost
J
Java Code Geeks
博客园 - Franky
月光博客
月光博客
Blog — PlanetScale
Blog — PlanetScale
NISL@THU
NISL@THU
D
Docker
小众软件
小众软件
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
A
Arctic Wolf
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
Forbes - Security
Forbes - Security
量子位
PCI Perspectives
PCI Perspectives
美团技术团队
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
有赞技术团队
有赞技术团队
腾讯CDC
P
Proofpoint News Feed
S
Security @ Cisco Blogs
G
Google Developers Blog
C
Cisco Blogs

博客园 - 范文轩

Sharepoint中的Feature Stapling功能 SharePoint 2010中的WebProvisioned Event Handler 如何向列表中添加数据值(开发篇补充REST) 如何向列表中添加数据值(开发篇) 如何向列表中添加数据值(管理员篇) 在SharePoint 2010中动态加载Visio Web Part 使用编程的方式来启动SharePoint的工作流 SharePoint 2010 WSP包部署过程中究竟发生什么? 如何查看SharePoint 2010的CU版本 SharePoint 2010多语言包的安装 在SharePoint 2010中使用Linq时候,请注意特殊字符 自定义ASP.NET WebApplication中调用SharePoint2010的对象 在Infopath 2010中调用Web Service 谈谈SharePoint 2010的客户端对象模型的性能问题 给Document Set里面添加文件夹 给Chart Web Part 添加过滤功能 SharePoint 2010的Form认证的用户注册功能 SharePoint 调查列表的自定义错误页面 Reporting Services 2008 and SharePoint 2010
InfoPath 2010调用REST的一个小应用
范文轩 · 2011-05-17 · via 博客园 - 范文轩

在做InfoPath 2007相关的项目中,我们经常使用InfoPath来调用SharePoint 2007的Web Service. 那么如今SharePoint 2010支持了REST,我们可以尝试调用REST。

需求:自定义一个SharePoint 2010 列表的表单。要求在用户输入“Title”时,检查一下当前列表中是否有相同Title的Item存在,如果存在的话,禁止表单的提交。

思路:使用InfoPath 2010调用REST实现。首先通过REST去列表中查询是否有title等于当前表单填写的Item,如果有的话,返回结果,并且禁止提交。如果查询不到,则允许提交。

第一步,自定义表单。点击列表项目的”自定义表单”,然后对表单做一些简单的处理,如下图。(列表的列有:Title, MyDate以及Query Result,这个是记录title的REST查询的返回结果的)

image

image

第二步,添加数据源. 我们需要添加一个“接收数据(Receive Data)”的数据源。我现在需要查询的是列表TestList,所用REST的URL如下:                         “http://servername/_vti_bin/listdata.svc/TestList

image

第三步,对InfoPath的Rule添加逻辑。

选中表单中的Title文本框,添加一个“当字段的值发生变化时(This Field Changed)”使用“查询数据(Query for Data)”.Rules的逻辑和调用Web Service(http://www.cnblogs.com/fanwenxuan/archive/2011/03/14/1984159.html)时的逻辑基本类似:拼接REST, 执行查询并且返回结果。

拼接REST:

concat("http://<ServerName>/_vti_bin/listdata.svc/TestList", "?$filter=Title eq ", "'", Title, "'")

image

执行查询:这里只需要做一个指向于Data Connection的“Query for data”的活动即可。

image

返回查询结果:(我这里对返回的结果的几个属性做了拼接,并且把结果的值返回到Query Result这个文本中)

image

第四步,增加验证。

我的验证逻辑是:如果查询没有返回结果,表示相同Title的Item不存在;如果有返回结果,表示存在相同Title的Item。对Title的文本控件在增加一个验证(validating)的逻辑:

Condition: Qurey Result is not blank.

ScreenTip: The item has existed.

第五步,发布表单。

接下来,就去验证你的逻辑吧!

image

注意:

1.在使用SharePoint 2010的REST的时候,首先要安装ADO.Net 3.5SP1:http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=3e102d74-37bf-4c1e-9da6-5175644fe22d

2.在你拼接REST时,你最好先在URL测试一下,检查是否能用。

参考:

http://blogs.msdn.com/b/infopath/archive/2010/02/11/add-a-dynamic-map-to-a-contact-form-using-rest-web-services.aspx