Recently, a friend said via MSN: "Ocean hasn't written anything recently ?". Think about what to write. From the actual project experience, there are indeed many things that can be written, at least a booklet can be written, but there is always no calm to write. The last time I went to Beijing, I was deeply touched by kb and ting mm. It was time to write something. I remember seeing bin in the bathroom, bin said with a smile, "how ocean is here", but he has found angry elements in his eyes, so they are shining fast, to avoid getting hurt again, think about what to write. After all, IW brings value to enterprises, and the IW camp also needs something new.
What do you want to write? I was just thinking about the problem I encountered when I went to Beijing at the end of September. I was so arrogant to teach kb, so let's write this. How to SetCodeThe infopath form template of is released to the SharePoint form library.
It is very easy to publish an infopath form template to the SharePoint form library. However, when we include custom code in infopath, we will find that after publishing it to the SharePoint form library, the custom code in the form cannot be run. Generally, an error with no permission is reported, as follows:
So what should we do? The actual steps are quite troublesome, but the SDK has a detailed introduction, but many people are not happy to read the SDK. Let's take a look at the general steps. Assume that a new template is created and placed in c: \ infopath \ testsave. xsn. The template contains a text box and a button. For example:
The following custom code is defined for the Save button:
Function ctrl1_5: onclick (eventobj)
{
// Write code here
If (xdocument. isdirty)
{
Xdocument. Save ();
}
}
Three steps are required to publish the form template to SharePoint.
1: Use regform.exe to set the form to full trust. This step is actually the most troublesome step. Where is regform.exe? The SDK for infopath must be installed. The SDK for infopath can be downloaded from this directory. After installation, the default path is "C: \ Program Files \ Microsoft Office 2003 developer resources \ microsoft office infopath 2003 SDK \ tools \ regform.exe ".
A: To get the urn, you need to trust the infopath template. First, you need to get the urn of infopath. This is simple. You can extract the form from the file to all the files in the form, you can also change the xsn to cab and decompress it with RAR. The obtained file contains a manifest. xsf. After opening it with notepad, we can see that the name attribute in <xsf: xdocumentclass> is the urn name we use here, and what I get here is "urn: schemas-Microsoft-com: Office: infopath:-myXSD-2005-11-05T12-31-24 ".
B: run the regform.exe registry list. Command Behavior: "C: \ Program Files \ Microsoft Office 2003 developer resources \ microsoft office infopath 2003 SDK \ tools \ regform.exe"/u urn: schemas-Microsoft-com: Office: infopath:-myXSD-2005-11-05T12-31-24/T Yes testsave. xsn. I will not explain the parameters. You can draw pictures. After running, a file named testsave. JS is generated. The command runs as follows:
C: run the testsave. js file until the registration is successful. As follows:
2: At this time, the form can run custom code locally, but it will still be unavailable when you publish it to SharePoint. In order to be able to use it in Sharepoint, we need to sign the form template. You can use infopath to directly create a certificate or use the certificate issued by CA to sign the certificate from tools> form Options> Security. For example:
3: You can then publish it to the SharePoint form library. the publishing process is no longer described. It is the same as a normal release.
After the release is complete, if you fill in the Form directly on the machine where the infopath is created, there will be no problem. However, if other machines enter a form from Sharepoint, the following message is displayed:
This is because the certificate is not trusted. Click the details button and select "Install Certificate" until the certificate is successfully installed. As follows:
Close infopath and then fill in the Form again. You will find that the check box is available, select the check box, and select open.
This is fine. Of course, the above Code is slightly faulty. When there is no file name in the file, click the Save button to prompt that there is no file name. After you save it as a file, click the "save" button and you will find that there is no problem.
In addition, I would like to tell you a 5-hour experience, that is, when creating a template, do not place the template in a directory with a Chinese name. Otherwise, an error will occur when running regform, an error "system error" is reported. This error took me at least five hours. I hope you will pay attention to it.
Welcome to the ocean Studio