InfoPath: Passing Command Line parameters to a new form

A frequent question from InfoPath users is “How can I pass parameters to a new InfoPath form when it is created?”

Unfortunately, there’s no built-in functionality for passing command-line parameters to infopath.exe.

BUT, that doesn’t mean it can’t be done J

Note that the solution below requires the InfoPath SP-1 Preview.

Solution:

Jscript files can instantiate InfoPath with a new form from a template using NewFromSolution().  Jscript can also access the InfoPath DOM and pass parameters to it.  And finally, Jscript files can also accept command-line parameters.

Usage: 

In my case, I wanted my C# application to pass parameters to a new Form.  Basically, the user (running my App) searches the SQL database for a customer (in my case, patient) account.  They can then view/edit all of that account’s data right in the app.  The user can then select a date and time for an appointment and click “Create Encounter.”  This button calls my jscript file, passing it the ID number, date, and time that were selected.  The Jscript file creates a new InfoPath form from the template, and fills in the ID number, date, and time.  The Form Template has the “AfterChange” event for the ID number text box set so that it queries the database with that ID number, which returns that customer/patient’s information and populates all relevant fields in the Form.  It then closes InfoPath, and my application simply says “Encounter file created.”

The form’s submit code puts it in a SharePoint library with a unique filename generated from the ID number and date/time of the appointment.

Calling the script:

In VB .NET, this is a simple matter of:

 
    
 
    
 
    
 
    
 
    
 
    

The Script:

 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    
 
    

This is a ready-to-go script file and all you need to change is A) The number of parameters B) The location of your template and C) The names of the fields you wish to populate.  You also may not want to submit the file or close InfoPath.  Or you may want to use oXDocument.SaveAs();

转自:http://geekswithblogs.net/bpaddock/archive/2004/05/14/4907.aspx

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值