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

推荐订阅源

博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
博客园 - Franky
IT之家
IT之家
V
Visual Studio Blog
博客园 - 【当耐特】
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
爱范儿
爱范儿
Hugging Face - Blog
Hugging Face - Blog
宝玉的分享
宝玉的分享
博客园 - 叶小钗
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
罗磊的独立博客
小众软件
小众软件
Jina AI
Jina AI

博客园 - Dragon-China

JS实现显示倒影的图片展示特效之改变图片显示大小 转:如何用C#获得文件信息以及扩展信息 C#制作WinForm控件 Office 2003 主 Interop 程序集的安装和使用 .NET 反编译工具及其插件 Extensible OLE Property Pages in .NET COM组件设计与应用之GUID和接口 用C#创建COM对象 ActiveX and Com Infopath中,自己编写的ActiveX控件,为何不能绑定数据到XML属性节点 一位软件工程师的6年总结本人读了深受启发,献给所有从事IT开发的人[转贴] InfoPath 的自动化和扩展 创建可绑定到 InfoPath 表单数据的 ActiveX 控件 Extending the InfoPath control set with custom controls InfoPath2007 开发人员的新增功能 在Infopath中使用自定义控件不能激发 OnPropertyChange 事件 ActiveX控件和它的容器 值得推荐的Infopath开发例子和资料 Custom Control support in InfoPath
InfoPath: Passing Command Line parameters to a new form
Dragon-China · 2007-12-14 · via 博客园 - Dragon-China

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:

Dim ProcID As Integer
Dim Proc As Process
ProcID = Shell("cscript script.js " + IDnum + " " + Date+ " " +Time + " " + AMPM)
Proc = Process.GetProcessById(ProcID)
Proc.WaitForExit(3000)
MsgBox("Form created.")

The Script:

//myscript.js
//parse parameters
if(WScript.Arguments.count()==4)
{
var param1 = WScript.Arguments.Item(0);
var param2 = WScript.Arguments.Item(1);
var param3 = WScript.Arguments.Item(2);
var param4 = WScript.Arguments.Item(3);
}
//Start the application
var oApp = new ActiveXObject("InfoPath.Application");
WScript.Echo("InfoPath Version: " + oApp.Version);
//Open an InfoPath document from the published template
var oXDocumentCollection = oApp.XDocuments;
var oXDocument = oXDocumentCollection.NewFromSolution("http://server/Forms/template.xsn";;);
// Get pointers to the target fields
var oID = oXDocument.DOM.selectSingleNode("//ID");
var oDate = oXDocument.DOM.selectSingleNode("//my:Date")
var oTime = oXDocument.DOM.selectSingleNode("//my:Time")
var oAMPM = oXDocument.DOM.selectSingleNode("//my:AMPM")
//Update the fields
oID.text = param1;
oDate.text = param2;
oTime.text = param3;
oAMPM.text = param4;
//Submit the Form
oXDocument.Submit();
//Close up shop
oXDocumentCollection = null;
oApp.Quit();
oApp = null;

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