Showing posts with label InfoPath. Show all posts
Showing posts with label InfoPath. Show all posts

Tuesday, December 16, 2008

InfoPath Adding Image to Button ImageButton

This KB article describes, in effect, how to create an ImageButton in InfoPath. 

Friday, October 3, 2008

Current configuration settings prohibit embedding username and password in the database connection string SharePoint InfoPath

You may get this error using an InfoPath form within SharePoint

Current configuration settings prohibit embedding username and password in the database connection string.)

SharePoint Central Admin -> Application Management -> Configure InfoPath Forms Services.

Check the box next to Allow embedded SQL authentication and click the OK button.

Thursday, October 2, 2008

Two InfoPath Contact Selector Controls On One Form

This information comes from the comments section of the InfoPath Team Blog.

Say you want to add two InfoPath Contact Selector controls to one InfoPath form. This sounds simple enough, create your group and then add the Person repeating node with the DisplayName, AccountName and AccountId fields like you normally would to the Person group. Trying to duplicate this same group again for the second contact selector control will throw an error because you can't have fields or groups with the same names. But knowing that the names have to be exact to have the contact selector control work, the question arises how do we duplicate the data source for the InfoPath contact selector control.

Well assuming you have a group named grpPersonSelector bound to the first InfoPath contact selector control. Create another group named really anything we'll use grpPersonSelectorTwo. Now right click on the Person repeating group under grpPersonSelector and click Reference and choose grpPersonSelectorTwo.

That's it, now the grpPersonSelectorTwo group can be bound to your second InfoPath contact selector control. Thanks Scott for this information.

Friday, September 5, 2008

form template cannot be opened in Microsoft Office InfoPath because it contains code that requires a version of the Microsoft Common language runtime

I received this error while trying to open an InfoPath form.

the form template cannot be opened in Microsoft Office InfoPath because it contains code that requires a version of the Microsoft Common language runtime that is not currently installed

I searched Google and MSDN but no solutions or even mention of this problem. After watching some tv last night and installing XP SP3 on my home computer it came to me that the CLR library needs to somehow get updated or fixed. But Windows had already been repaired and Office 2007 reinstalled, that should have fixed it but nope.

Hmmm.... I got it, let's try to install .NET Framework 3.5 SP1 and see what happens. There have been improvements made to the CLR in 3.5 SP1 and should maybe update the missing dlls. Sure enough after installing 3.5 SP1 and trying to open the form again it opened without problems.

So installing the latest version of the .NET framework fixed the issue.

Tuesday, July 29, 2008

Convert InfoPath form to PDF Document

I wanted to know how to do this for a long time now but never really spent the time to figure it out. And sometimes that's a good thing because people do it for you. As in this sample about how to convert the InfoPath form to a PDF.

http://aspalliance.com/1466_Printing_InfoPath_2007_WebBased_Forms_to_PDF.6

The solution uses an open source project for the PDF generation called iTextSharp. I haven't tried it yet but I also don't know of a lot of free pdf libraries.

Monday, July 28, 2008

Programmatically remove InfoPath digital signature

This code will need to be placed within the backed InfoPath code, although just like before I'm going to try doing this with a web part. Speaking of which, I was able to remove the Excel digital signatures using a web part however it prompted for each signature that was to be removed and there is no way to get rid of that prompt so that sucked.

Anyway, here is how to do it in InfoPath. Basically get the signature node, go to the signature child of that node and delete it.

XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();

if(this.Signed) //then unsign it
{
XPathNavigator xSignedSection = xnDoc.SelectSingleNode("my:myFields/my:signatures1/my:signatures2", this.NamespaceManager);

if (xSignedSection.HasChildren)
{
xSignedSection.MoveToChild(XPathNodeType.Element); xSignedSection.DeleteSelf();
}

}

Thursday, July 24, 2008

InfoPath Percentage Symbol Field

This applies to InfoPath 2007 as well.

That's just wrong:

Note Microsoft Office InfoPath 2003 does not add percent symbols to numbers that are formatted as percentages. To add a percent symbol to a control's label, click where you want the percent symbol to appear, and then type %.

http://office.microsoft.com/en-us/infopath/HP010938331033.aspx

Tuesday, July 22, 2008

EmailSubmitConnection :How to add custom email to an InfoPath email data connection EmailSubmitConnection

EmailSubmitConnection : Often times I need to add some more information to an email that is sent from InfoPath besides just a view of the form. Sometimes I want to add fields and such to the body of the email but just end up adding the fields to the subject line since there is no way without writing code to include fields in the introduction field of the email. I hope with Office 14 they make this possible without writing code, but for right now let's see how to do it.

First, you need to create a data connection (EmailSubmitConnection) that sends an email to someone within the InfoPath data connections. This data connection needs to be created so we can reference it in our code.

Second get into the code behind of the form, I'm using C# for InfoPath 2007 so those with InfoPath 2003 may have to figure this out for themselves but hopefully this gives them some clues.

Within, probably a button click event, I get a reference to the email data connection. The "email connection" is the name of the data connection I created in the first step.

EmailSubmitConnection emailDataConnection = (EmailSubmitConnection)this.DataConnections["email connection"];

//add your custom message to the introduction, say hello to yourself
XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();
XPathNavigator fullName = xnDoc.SelectSingleNode("my:myFields/my:txtFullName", this.NamespaceManager);
emailDataConnection .Introduction = "My custom introduction with some fields. Hello " + fullName.Value;

//submit the data connection which sends the email
emailDataConnection .Execute();

As you can see, just get a reference to the data connection (EmailSubmitConnection), set the Introduction property and execute. This can also be accomplished for the FileSubmitConnection and WebServiceConnection objects, so you can write code to execute these connections and set some custom properties before making the submit. Hope this helps someone.

Monday, July 21, 2008

InfoPath Rules vs Code

When writing custom code behind for an InfoPath form you should keep in mind that when used on a button with other rules that the rules will run before the code. This means that if one of your rules "Closes the form" that your code will have to do this instead, otherwise the rule will close the form and your code will never run.

There is no way to switch the OoE or Order of Execution within InfoPath. Here is a sample to close the form in code in a js script code behind. There is also no need to sign the form unless the code interacts with the SharePoint OM.

Application.XDocuments.Close(0); //will close form but keep InfoPath open

Application.Quit(bool) //will exit InfoPath and if true force an exit, if false will prompt user if they want to save the form

I used true because in a rule I submit the form so the code can go ahead and quit InfoPath.

Wednesday, July 9, 2008

Enable InfoPath autocomplete feature

This feature is actually part of IE and needs to be enabled within IE. This seems sort of odd because not all InfoPath forms are web based but also kind of nice because the setting is in one place. Here are the steps:

Within IE go to the tools menu, click Options, and then click the General tab.
Under System options, click Internet Options, and then click the Content tab.
Under Personal information, click AutoComplete.

You should be able to set your autocomplete settings from that configuration.

This came from http://office.microsoft.com/en-us/infopath/HP010967791033.aspx

Monday, July 7, 2008

InfoPath Form Template Format Structure Specification

Well I found this spec from MS regarding InfoPath, just updated the last week of June 2008. Their spec still indicates that the date picker button has a tab index of -1 instead of (tabIndex="TAB_INDEX")? like the other controls.

http://download.microsoft.com/download/8/5/8/858F2155-D48D-4C68-9205-29460FD7698F/%5BMS-IPFF%5D.PDF

I wonder if they haven't had complaints about this or if there is a technical reason why -1 is hardcoded as the tabindex of that control.

InfoPath Tabbing bug - Update #1

I saved the form as its source files and broke open the guts of the form. Looking at View1.xsl (since I didn't rename the default view), I found this by the date picker control.

button class="xdDTButton" title="" xd:xctname="DTPicker_DTButton" xd:innerCtrl="_DTButton" tabIndex="-1">
img title="" src="res://infopath.exe/calendar.gif"/
/button


This button is the small calendar image that when clicked opens up the date picker control. As you can see this has a tabIndex of -1 instead of the 12 that the control should have. Below is the span associated with the text portion of the date picker. Notice how that has the correct tab index.

span class="xdDTText xdBehavior_FormattingNoBUI" hideFocus="1" title="" contentEditable="true" tabIndex="12" xd:xctname="DTPicker_DTText"

MS should have made the button have a tab index of 12 too so that the next tab action goes to the next field instead of dropping down to the rest of the form.

Next question, can I change the source files without breaking the rest of the form?? What about Drop Down Lists and Radio buttons? I suspect the same thing is happening...

Remove Warning - this form is using your identity to connect to data sources

When connecting to a web service or SQL server from InfoPath client forms that you access from a SharePoint site you may receive this warning each time you open the form.

"This form is using your identity to connect to data sources"

This gets really annoying and your users may be confused. So advise them to Enable Access data sources across domains within IE -> Security Settings. The form should be within a Trusted Site or within the Local Intranet Zone so this should be ok because group policy should dictate what sites are in these zones, and if your IT group is good only very very safe sites should be in those zones, like for instance your local SharePoint intranet site.

Wednesday, July 2, 2008

InfoPath Tabbing Tab Index bug

I have an InfoPath form with controls defined below.


TextBox - Tab Index is 1

TextBox - Tab Index is 2

Date Picker - Tab Index is 3

TextBox - Tab Index is 4

TextBox - Tab Index is 0


If I tab through these fields, it goes down the line 1, 2, 3, 4, 0 as expected. However, if I tab from 1 to 2, 2 to 3 and then choose a date using the calendar and then tab again it goes down to the textbox with tab index of 0.

Why does this happen? Because the small calendar icon seems to be it's own control and gets focused on, it's tab index is presumably 0 even though the entire Date Picker control is 3. So when I tab from the calendar icon it goes to the next tab index of 0 which is expected. However, this is not an expected behavior from a user perspective or from any other perspective for that matter.


That entire Date Picker control should have a tab index of 3 not just the text portion of the control but the entire control including the small calendar icon.


This same behavior seems to occur for radio buttons and drop down controls as well. If instead you replace the Date Picker with a Drop Down control and the user selects a value, the next tab is to a control with a tab index of 0, even though it's expected that it should be 4 (using the example above).

I would consider this a bug that needs to be fixed for Office 14. Probably not important enough for them to fix it in a service pack for Office 2007, even though that would be nice.

Wednesday, June 25, 2008

The selected file was not found - InfoPath Form Services

I created an internal InfoPath form that was hosted in the InfoPathViewer Web Part and put a file attachment control on it. I kept getting "the selected file was not found" when attaching a document to the form. To solve this I needed to add a Content Editor Web Part with the following code in the source. This encoding is crucial for the ability to attach attachments to InfoPath forms hosted on Forms Server or within the InfoPathViewer Web Part.

script type="text/javascript" aspnetForm.encoding = "multipart/form-data"; /script

Tuesday, June 24, 2008

Create a Save As dialog box in InfoPath

Just pop the following code into your VSTO project for the button click event.

FileDialog oDialog = new SaveFileDialog();
oDialog.DefaultExt = "xml";
oDialog.Filter = "InfoPath Form (*.xml)*.xml";
if(oDialog.ShowDialog() == DialogResult.OK)
{
string sFilename = oDialog.FileName;
this.SaveAs(sFilename);
}

InfoPath .NET Programmability

Need to install the programmability feature for InfoPath otherwise you'll receive this error:

InfoPath cannot open the selected form because of an error in the form's code.The required version of the Microsoft .NET Framework is not installed on your computer, or the InfoPath Primary Interop Assembly (PIA) is not registered. Use Add or Remove Programs in Control Panel to make sure that the required version of the Microsoft .NET Framework is installed. Or install it using Windows Update and run the Setup program again to confirm that the corresponding version of the .NET Programmability Support is installed, or contact your system administrator

Wednesday, June 18, 2008

Programmatically add InfoPath mail attachment (mime types)

In order to send an attachment within a workflow I had to write my own method since the out-of-the-box SendEmail activity doesn't support attachments. While doing this I had to figure out how to attach an InfoPath form to the e-mail. Using the code below I was able to accomplish this task. Not very obvious at first but after diving into what is actually going on it makes perfect sense.

Stream formStream = spItem.File.OpenBinaryStream();
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/xml");
Attachment attachment = new Attachment(formStream, ct);
attachment.Name = spItem.File.Name;
mailMessage.Attachments.Add(attachment);

Hope this helps someone who is trying to do the same thing. There is an activity out on Codeplex for this but that only applies to SharePoint designer workflows. If I had time and there was a need for it, I would create a VS Workflow activity for this.

SharePoint Integration with Outlook Web Access (OWA)

I recently presented a SharePoint demonstration to a select few managers and one of the items that came up during discussion is that Microsoft says SharePoint integrates with OWA. While this is completely true there are a number of caveats that users should be aware of. And then just today there was a post on the SharePoint newsgroups about how to accomplish this.

There are two ways that I know of that OWA can be set up in terms of authentication either Forms based or NTLM based. I will describe the pitfalls of integrating both authentication methods with SharePoint. Most people will look to put the OWA inbox and calendar on the user's My Sites, which by all means can be done however you may want to reconsider after reading this article.

OWA Forms Based Authentication

If you try to configure the integration with Forms based you'll quickly find that the web part simply displays your OWA logon screen. In order to seemlessly integrate you will need a developer to write a Single Sign-On application (SSO) that automatically passes the user's current credentials onto the OWA logon screen. I've done it before, it's not too hard provided you know SharePoint and are good at SSO applications. But it's not for novice SharePoint developers.

NTLM Based Authentication

If you try to configure the integration with NTML based OWA you'll quickly notice that you can add the web part to the page and then you get prompted for your credentials, after entering your credentials you get passed onto OWA. There is no solution that I know of to seemlessly logon the user to OWA from SharePoint using this authentication method. And since that's the case, why not just host the entire OWA within a Page Viewer Web Part instead of having a web part for each feature of OWA and thus requiring the user to logon multiple times. In fact, instead of just hosting it within an iframe, why not just give the user a link to OWA so the page isn't crunched into an iframe with SharePoint.

Needless to say, seemless integration between OWA and SharePoint is not currently available, possible, but not like it should be.

Tuesday, June 17, 2008

Designing InfoPath forms for performance

Very nice start to what looks like will be a number of articles describing how to design InfoPath web-based forms for high performance. It describes some common issues of poor performing web forms. The next article looks interesting to me about the differences in performance between the rich client based forms vs. the web based ones.

http://blogs.msdn.com/infopath/archive/2008/05/09/designing-browser-enabled-forms-for-performance-in-infopath-forms-services.aspx