深入浅出InfoPath——让管理员来部署InfoPath表单

应用场景

我们(乙方)在给客户提供基于InfoPath表单(尤其是包含托管代码的)的工作流解决方案的时候,常常需要客户(甲方)的SharePoint管理员来帮忙在安装SharePoint Server的服务器上部署,而管理员不需要知道需要哪些步骤来完成InfoPath Service的部署,更不愿意看到通过繁琐的操作来完成预定的任务。大家都知道企业软件有个特点:尽可能少的Code。要想问题少的最好办法就使用尽可能少的代码。所以我们使用命令来部署InfoPath Service自动化部署InfoPath表单是最好的办法。

基本原理:

使用bat命令或者PowerShell来执行SharePoint管理命令。SharePoint为管理员提供了以下部署InfoPath表单的命令:
%STSADM% -o RemoveFormTemplate -filename

%STSADM% -o uploadformtemplate -filename

%STSADM% -o deactivateformtemplate -url %SITEURL% -filename

%STSADM% -o activateformtemplate -url %SITEURL% -filename

参考方案

我们现在需要客户的SharePoint管理员来重新部署我们提供的出差申请流程。

1 文件结构如下放置

2 bat脚本

@SET STSADM="%programfiles%\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE"
@
SET SITEURL="https://www.cnblogs.com/sites/mingle"

%STSADM% -o RemoveFormTemplate -filename
"Mingle.FormTemplates\BusinessTripRequest.xsn"
%STSADM% -o execadmsvcjobs

%STSADM% -o uploadformtemplate -filename
"Mingle.FormTemplates\BusinessTripRequest.xsn"
%STSADM% -o execadmsvcjobs

%STSADM% -o deactivateformtemplate -url %SITEURL% -filename
"Mingle.FormTemplates\BusinessTripRequest.xsn"
%STSADM% -o execadmsvcjobs

%STSADM% -o activateformtemplate -url %SITEURL% -filename
"Mingle.FormTemplates\BusinessTripRequest.xsn"
%STSADM% -o execadmsvcjobs

pause

如果我们第一次部署InfoPath表单,可以仅使用uploadformtemplate和activateformtemplate即可。

补充说明

a、execadmsvcjobs此命令可以保证下达的任务马上执行。我们在实际部署中经常遇到部署后10多个小时,新的InfoPath设计才生效。

b、为什么我们重新部署的时候需要先反激活InfoPath表单,然后再重新激活呢?因为InfoPath表单新的设计使用的站点不重新激活的话,新的设计信息将不生效。

以上问题在我们手工部署InfoPath表单的时候也常常碰到同样的问题。

 

 

扩展阅读

在SharePoint2010中可以通过Feature来部署沙箱的InfoPath表单,以下命令可供使用

Uninstall the existing solution (based on the from file name):
Uninstall-SPInfoPathFormTemplate -Identity Exampleform.xsn
Install the new solution (based on the from file name):
Install-SPInfoPathFormTemplate -Path C:\Form.xsn
Disable feature on site collection level
Disable-SPInfoPathFormTemplate -Identity "Form.xsn" -Site http://SPSite 
Enable feature on site collection level
Enable-SPInfoPathFormTemplate -Identity "Form.xsn" -Site "http://SPSite" 

 

posted @ 2011-01-30 16:49  风影极光  阅读(658)  评论(0编辑  收藏  举报