infopath 自动递增_InfoPath表单中的递增顺序编号

infopath 自动递增

A question that is asked often, is how to generate sequential numbers in InfoPath Forms. The best way to achieve this is to use a SQL database, along with a stored procedure and a web service to connect Forms Services to the DB.

经常问到的一个问题是如何在InfoPath Forms中生成序列号。 实现此目的的最佳方法是使用SQL数据库以及存储过程和Web服务将Forms Services连接到DB。

The first thing to do is create a database table to store and update the numbers. Please see the image below.

首先要做的是创建一个数据库表来存储和更新数字。 请参见下图。

Image 1

The database needs nothing fancy, just a column I called CurrentNumber. The column type is an integer. I called the database table tblSequenceNumber.

数据库不需要花哨的东西,只需要一列我称为CurrentNumber的列即可。 列类型是整数。 我将数据库表称为tblSequenceNumber。

The next thing to do is create a stored procedure that will be used to update the number. This will be a middle man between the web service we will create later and the numbering database. The stored procedure should look something like this:

接下来要做的是创建一个存储过程,该过程将用于更新数字。 这将是我们稍后创建的Web服务和编号数据库之间的中间人。 存储过程应如下所示:

Stored Procedure

As you can see, the stored procedure is now called spGetNextSequenceNumber.

如您所见,该存储过程现在称为spGetNextSequenceNumber。

The next step is to create a web service that will allow InfoPath/SharePoint to talk to the DB without running into any double-hop or authentication issues. Without the web service, this would not work. The web service should look something like this:

下一步是创建一个Web服务,该服务将允许InfoPath / SharePoint与数据库进行对话,而不会遇到任何双跳或身份验证问题。 没有网络服务,这将无法工作。 Web服务应如下所示:

Web Service

The web service will now connect to the stored procedure and update the number DB incrementally. The webservice should be called something.asmx and stored in the following location on the front end server(s):

Web服务现在将连接到存储过程,并逐步更新数字数据库。 该Web服务应名为something.asmx,并存储在前端服务器上的以下位置:

%Program Files%\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\Webservices

%程序文件%\公用文件\ Microsoft共享\ Web服务器扩展\ 12 \ TEMPLATE \ LAY OUTS \ Webse 服务

Now we get to the fun part. Applying all of this to an InfoPath form.

现在我们进入有趣的部分。 将所有这些都应用到InfoPath表单。

The first thing to do is add the web service as a data connection within the form. We go to Tools>Data Connections

首先要做的是将Web服务添加为表单中的数据连接。 我们转到工具>数据连接

Tools>Data Connections

Then select Add>Create a new connection to>Receive data

然后选择添加>创建新连接以>接收数据

Receive Data

The select Web service

选择Web服务

Web Service

You then need to enter the location of the web service file that we are going to read. In the image I have replaced my url with some text. You need to enter the url that you would use to access SharePoint, followed by _layouts/webservices/the name of your file.asmx?WSDL

然后,您需要输入我们将要读取的Web服务文件的位置。 在图像中,我用一些文本替换了我的网址。 您需要输入用于访问SharePoint的URL,然后输入_layouts / webservices /文件名。asmx?WSDL

Web service URL

If you have formatted all of  this correctly, on the next page you will be presented with the available actions from the web service file:

如果已正确格式化所有这些格式,则在下一页上,将显示Web服务文件中的可用操作:

Web service list

We need to select GetNextSequenceNumber and then click next

我们需要选择GetNextSequenceNumber,然后单击下一步

Next

At this point it is ESSENTIAL that you unselect Automatically retrieve data when form is opened

此时,您必须取消选择“打开表单时自动检索数据”

Untick automatic

If we don't, then every time we open the form, the number in the database table will increment by 1.

如果不这样做,那么每次打开表单时,数据库表中的数字都会增加1。

Now it gets REALLY fun. We need to use this data connection to populate a field on the form.

现在,它变得非常有趣。 我们需要使用此数据连接来填充表单上的字段。

The first thing to do is add a text box to the form

首先要做的是在表单中添加一个文本框

Text box

Once we have done this, we go Tools>Form Option>Open and Save>Rules

完成此操作后,我们进入“工具”>“表单选项”>“打开并保存”>“规则”

Rules

For the purposes of this article, the filed is called Field1. We then select Add to add a new rule and then Set Condition

为了本文的目的,该字段称为Field1。 然后,我们选择添加以添加新规则,然后选择设置条件

Add rule

We then need to specify Field1 is blank

然后,我们需要指定Field1为空白

Field1 blank

This is so we update the field the first time we create the form only, and NOTevery time we open the form.

这样一来,我们仅在第一次创建表单时更新字段,而不必每次打开表单时都更新该字段。

We the select Add Action>Query using a data connection and select our data connection from the drop down

我们选择“添加操作”>“使用数据连接查询”,然后从下拉列表中选择我们的数据连接

Add action

This gets the next number from the database and stores it in the cache. It also runs the stored procedure which increments the number in the database.

这将从数据库中获取下一个数字,并将其存储在缓存中。 它还运行存储过程,该过程将增加数据库中的数字。

We then need to select Add Action once more and select Set A Fields Value, then select Field1. We the select the FX button and change the data source in the drop down at the top to our GetNextSequenceNumber data connection. Then expand the dataFields portion, expand GetNextSequenceNumberResponse and select GetNextSequenceNumberResult

然后,我们需要再次选择“添加操作”并选择“设置A字段值”,然后选择“ Field1”。 我们选择FX按钮,然后将顶部下拉菜单中的数据源更改为GetNextSequenceNumber数据连接。 然后展开dataFields部分,展开GetNextSequenceNumberRespo nse并选择GetNextSequenceNumberResul Ť

Add second action

This will then give us the following

然后,这将为我们提供以下内容

Result

We can then do some great stuff such as concatenating a prefix or suffix to the number for use in invoicing etc

然后,我们可以做一些很棒的事情,例如将前缀或后缀连接到用于发票的编号等

Concat

We can then save out of everything and preview the form. It should look like this

然后,我们可以保存所有内容并预览表单。 它应该看起来像这样

Preview

And that, in a relatively large nutshell, is how to build a bulletproof, autoincrementing, sequential numbering system for InfoPath.

概括地说,这就是如何为InfoPath构建防弹,自动递增,顺序编号系统。

As always, and comments or feedback is welcome.

与往常一样,欢迎发表评论或反馈。

翻译自: https://www.experts-exchange.com/articles/658/Incremental-sequential-numbering-in-InfoPath-forms.html

infopath 自动递增

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值