Archive for the 'InfoPath' Category

10
Jul
13

InfoPath 2010 Form: Redirect to your source Page once form has been closed

I’ve noticed that this topic has been asked about by many people and I thought I’d offer up what I did to eliminate this problem.

For those not familiar with this issue, when you create an InfoPath form and create Submit and Cancel buttons, it is likely you want the Cancel operation to redirect or return you to your originating page.  Some folks want to display a "Thank you" page after a submit and then return to their originating page.  While you can do this with scripting, such as JavaScript found here, I think I have a simpler method that doesn’t require you write any custom JavaScript (although it does use a built-in SharePoint JavaScript function).

The trick I used was to open the form in a dialog.  That way, when you click Cancel, the dialog is dismissed and you remain on the same page from which you opened the dialog.

Here’s some example html.

<a href="javascript:OpenPopUpPage(‘uploadfile.aspx?ProjectID={@PMO_x0020_Project_x0020_ID}’, RefreshPage);">

In this case, uploadfile.aspx is located in the pages library and is a custom page with an InfoPath form web part on it.  The custom page also has a URL filter on it that is connected to the form.  The parameter, ProjectID, is a URL parameter that is passed to the form through a web part connection.

Here is an image that has the above hyperlink (Upload File) anchored to it.

image

This opens the page below in a dialog.  Notice how the Project ID is defaulted on the form using a URL parameter that is sent to the form web part using a web part connection.

image

When Cancel is clicked, the dialog is dismissed and we’re right back where we started.

For the "Thank you" page, I’d recommend creating another view in InfoPath and simply switching views after the submit with your "thank you" text and provide an OK button to close the form.

25
Nov
12

Unsupported Expression in InfoPath 2010

 

This is a weird one.

Situation:

Going back to a SharePoint 2007 site formerly published with InfoPath 2007.  Downloaded the form template and made some changes.  When I went to re-publish I encountered an “unsupported expression” error.

image

The actual long message was as follows.

The following expression could not be parsed because of a syntax error or because it uses an undefined namespace prefix or unsupported function:  pc:DisplayName

image

This appeared to have been coming from one of the people pickers (circa 2007 variety) but copying the Xpath on each of them yielded no easily identifiable pc:DisplayName.

/my:myFields/my:EmployeeManager/my:Person/my:DisplayName

/my:myFields/my:EmployeeGroup/my:TerminatingEmployee/my:Person/my:DisplayName

I went back to the original template with no changes and it didn’t throw the same error during publishing.

I changed the Form type from Web Browser Form (InfoPath 2007) to InfoPath 2007 Filler Form and attempted publishing.  The error went away.

image

So, I changed it back to Web Browser Form (InfoPath 2007) again…the way it originally was.  The error stayed away and I published the form. 

However, after publishing, the error came back.  Sad smile  So I decided to look “under the covers.”

I saved the XSN as source files and looked within all the files.  I was able to find where the pc: schema infiltrated my form template.  Within view1.xsl I found the offending pc:DisplayName, and all the other related pc: references. 

image

I’m not sure how this made its way into the form template, as I never specifically made this change, nor do I know how one would force this. 

</xsl:if>

                                        <param NAME="ButtonFont" VALUE="Verdana,12,0,400,0,0,0"/>

                                        <param NAME="ButtonText" VALUE=""/>

                                        <param NAME="DisplayNameXPath" VALUE="pc:DisplayName"/>

                                        <param NAME="ObjectIdXPath" VALUE="pc:AccountId"/>

                                        <param NAME="ObjectTypeXPath" VALUE="pc:AccountType"/>

                                        <param NAME="SiteUrlXPath" VALUE="/Context/@siteUrl"/>

                                        <param NAME="SiteUrlDataSource" VALUE="Context"/>

                                        <param NAME="NewNodeTemplate" VALUE="&lt;pc:Person xmlns:pc=&quot;http://schemas.microsoft.com/office/infopath/2007/PartnerControls&quot;&gt;
    &lt;pc:DisplayName&gt;&lt;/pc:DisplayName&gt;
    &lt;pc:AccountId&gt;&lt;/pc:AccountId&gt;
    &lt;pc:AccountType&gt;&lt;/pc:AccountType&gt;
&lt;/pc:Person&gt;"/>

                                        <param NAME="BackgroundColor" VALUE="2147483653"/>

                                        <param NAME="MaxLines" VALUE="4"/>

                                        <param NAME="Direction" VALUE="0"/>

I did a simple “find and replace” on all the pc: occurrences with my: and saved and tested my work.  All appears to be okay.

Sure would be nice to know how this happens!

21
Nov
12

InfoPath Blog Silent?

Is it just me, or has anyone noticed the InfoPath team blog at http://blogs.msdn.com/b/infopath/ has been silent for the last year and a half?  Did they move it somewhere else when I wasn’t looking?  Or, did I finally look up for a minute, only to find the world has passed me by…again?

02
Oct
12

Launch form in a dialog doesn’t work correctly when displaying a list in datasheet view

This was driving me nuts.  I had a custom list in SharePoint 2010 and I wanted the new item form to NOT open in a dialog.  No matter what I did, it kept opening in a dialog.

image

Then I stumbled upon what was causing my issue!  Whenever the list was displayed in a datasheet view (which was my default), the new item form would always display in a modal dialog.

List displayed in datasheet view.

image

 

 

 

 

 

 

 

 

 

 

Create a new entry…

 

image

 

…and modal dialog is displayed (notice no master page "chrome”).

 

image

 

Change to standard view…

 

image

 

…and the form is opened up in single page mode (notice master page “chrome”).

 

image

What’s up with that?

An interesting thing to note is this problem also exists with Calendar lists.  If you display a calendar list in anything other than a normal list view, the “Launch forms in a dialog” will not be respected when set to “No.” 

Again, if we set “Launch forms in a dialog” to “no” and view the calendar in “Calendar” view…

 

image

 

…and attempt to create a new event while in this view…

 

image

 

…the form opens in a dialog.

 

image

 

If we change to the “All Events” view and attempt the same thing…

 

image

 

The form is opened in a new page (no dialog).

 

image

 

Perhaps this is the designed behavior, but if it is, I would recommend renaming the option to “Launch forms in a dialog when showing items in standard view.”

The description of the option would lead one to believe there might be times when a dialog would not be displayed when you would expect it to be displayed…not the other way around.

 

image

 

I guess I shouldn’t be disappointed when I get “free” dialog forms.

 

Keywords:

Launch form in a dialog broken

Launch form in a dialog doesn’t work for custom list

List view affects dialog form

19
Dec
10

Removing the view selector from a Sharepoint 2010 infopath form

If you have created custom InfoPath forms for a list in SharePoint 2010 and you have custom views for each of the New, Edit and View forms, you might find the InfoPath view selector showing up when you don’t want it to.  This could allow users to change to the Edit view on your New item form, for example.

image

To fix this, you can select the View Properties from the Page Design menu in InfoPath and uncheck the “Show on the View menu when filling out the form” option.

image

 

image

If all of your views have this unchecked, then the view selector will not appear on the SharePoint InfoPath form.

31
Mar
10

All Toolbars Missing from InfoPath 2007

An advanced InfoPath client of mine was working in InfoPath 2007 the other day and suddenly, all his toolbars disappeared.  Even the toolbar with the File menu on it was gone.  The only thing that showed up in design mode was the task pane on the right.

After talking with him, he told me he had repaired and uninstalled/reinstalled InfoPath but the problem remained.  After searching around the registry and thinking that I might have found something at HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\Toolbars\Settings\Microsoft Office InfoPath, through trial and error we found that that key didn’t have any effect on the missing toolbar problem. 

I had him log on as another user and start up InfoPath and the toolbars were there, so it certainly appeared to be a user settings issue.  I found this article about Excel 2000 and decided to poke around and see if InfoPath had the same type of toolbar settings.  Sure enough, in C:\Documents and Settings\[UserName]\Application Data\Microsoft\InfoPath there is an infopath.tbs file.  After renaming this file and restarting InfoPath the toolbars reappeared.

Don’t know what happened to corrupt this file, but now we know how to fix it.

19
Feb
10

InfoPath Code to Hide All Toolbars When Filling Out a Form

There are probably several ways to do this, but this seemed pretty straightforward to me.  The code loops through the CommandBars collection that is part of Microsoft.Office.Core and sets the Enabled property to false.  If you want, you can selectively inspect each toolbar in the collection and enable/disable specific ones.

You can use the Context Changed Event to set a spiffy title for your form.  Be aware that, if the Context Changed Event is grayed out, you need to change the form’s browser compatibility options so it is not able to be opened in InfoPath Forms Services.

image

Uncheck the box “Design a form template that can be opened in a browser or InfoPath.”

image

Since we are using code, you’ll have to fully trust the form and sign it.

image

We’re using C# in this example, so set the form template code language to C#.

image

Add a reference to Microsoft.Office.Core by browsing to MSO.DLL in your Microsoft Shared folder.  You can see it here in my list of recent references.

image

image

Now you should be able to add the USING statement for Microsoft.Office.Core.

 

using Microsoft.Office.InfoPath;
using Microsoft.Office.Core; // Required for Commandbars
using System;
using System.Xml;
using System.Xml.XPath;
using System.Windows.Forms;
using mshtml;

namespace Test_Form
{
    public partial class FormCode
    {
        #region EventHandlers
        public void InternalStartup()
        {
            EventManager.FormEvents.Loading += new LoadingEventHandler(FormEvents_Loading);
            EventManager.FormEvents.ContextChanged += new ContextChangedEventHandler(FormEvents_ContextChanged);           
        }
        #endregion

        #region Toolbars

        public void FormEvents_ContextChanged(object sender, ContextChangedEventArgs e)
        {
            if (this.New)
            {
                this.Application.ActiveWindow.Caption = “Fill out my form!”;
            }
        }

        public void FormEvents_Loading(object sender, LoadingEventArgs e)
        {
            HideAllToolbars();
        }

        void HideAllToolbars()
        {
            // The main toolbar with the file menu will be hidden (msoBarTypeMenuBar)
            // along with all the other toolbars (msoBarTypeNormal)
            // if HideToolbarsFlag is true in the datasource
            /* List of enumerated menu bars
                Menu Bar msoBarTypeMenuBar 1
                Standard msoBarTypeNormal 2
                Print Preview
                Formatting
                Tables
                Ink
                Task Pane
                Property Editor
                Office Clipboard
                XML Source
                Research
                XML Document
                Signatures
                Document Actions
                Clip Art
                Selection and Visibility
                Document Management
                Document Updates
                Mail Merge Panes
                Fax Service
                Meeting Workspace
                Attachment Options
                Clipboard
                Envelope
                System
                Online Meeting
             * */
            XPathNavigator root = MainDataSource.CreateNavigator();
            string hideToolbarsFlag = root.SelectSingleNode(“//my:HideToolbarsFlag”, NamespaceManager).ToString();
            bool flag;
            if (hideToolbarsFlag.ToLower() == “true”)
            {
                flag = true;
            }
            else
            {
                flag = false;
            }

            CommandBars myCommandBars = this.Application.ActiveWindow.CommandBars as CommandBars;
            CommandBar myCommandBar = (this.Application.ActiveWindow.CommandBars as CommandBars).ActiveMenuBar;
            foreach (CommandBar item in myCommandBars)
            {
                //MessageBox.Show(item.Name.ToString() + ” ” + item.Type.ToString() + ” ” + item.Index.ToString());
                if (flag == true && (item.Type == MsoBarType.msoBarTypeMenuBar || item.Type == MsoBarType.msoBarTypeNormal))
                {
                    item.Enabled = false;
                }
            }
        }
        #endregion

    }
}

In order to control whether the toolbars are displayed or not, a field is added to the data source.  Add the element, HideToolbarsFlag, that will control whether or not to hide the toolbars.

image

image

This bit of code retrieves it’s value.  If you set the default value to true, it hides the toolbars; anything else, it doesn’t.

string hideToolbarsFlag = root.SelectSingleNode(“//my:HideToolbarsFlag”, NamespaceManager).ToString();

And now preview your form.

image




Asif Rehmani’s SharePoint Videos

SharePoint-Videos

Click to access a wealth of SharePoint videos

SharePoint Rx

SharePoint Rx Home

Categories

Posts by Date

December 2019
M T W T F S S
« Jun    
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
Support Wikipedia