Cannot publish InfoPath forms or cutomized list forms in SharePoint lists (2010)

Christmas Holidays are over, and what could be more fun than coming back from holidays to error messages through SharePoint.

It seemed when a user tried to edit an infopath form of their site collection they were unable to republish the form getting the following error message:

Error Message

“The publish operation could not be completed. It cannot be determined if the form template was successfully published. Try publishing the form template again, or change the list settings to use the default SharePoint form”

It didn’t matter how little was changed in the form or whether it was a form libray or trying to customize the form of a regular SharePoint List:

Customize Form

viewing the details of the error message:

“InfoPath cannot connect to the server. The server may be offline, your computer might not be connected to the network, or InfoPath Forms Services 2010 might not be enabled on the server. To fix this problem, start by checking your network connection, and then trying again.”

From this we can narrow down the issue to be with InfoPath Forms Services since we are able to connect to the Site collection fine.

Since this was not an issue with other site collections we can narrow it down further that it is only with the InfoPath Site Features (IPFSSiteFeatures). This is a hidden feature in all site collections and can only be viewed through PowerShell. I found by simply disabling an re-enabling this feature fixed the problem.

PS C:\> Disable-SPFeature "IPFSSiteFeatures" -url "http://Server/Sites/SiteCollection"
PS C:\> Enable-SPFeature "IPFSSiteFeatures" -url "http://Server/Sites/SiteCollection"

Hope this helps

Advertisements

Alternative for using Roles in InfoPath Browser based forms

Roles in InfoPath are a great way for breaking your form up and identifying users for handling certains tasks/sections of the form. However a common problem for people are that InfoPath User Roles can be cumbersome, as you need to republish the form each time you want to add users to it and they are not compatible with Browser Enabled forms.

A simple workaround to this is through the use of SharePoint Lists and SharePoint profile webservices. The object is to use the SharePoint “GetUserProfileByName” webservice to determine who is currently browsing the form, then based on a criteria that checks that user against a SharePoint list of users that will decide which sections of the form they are able to see.
I’ve given out the steps in a simple example below

To get started first you’ll need to figure out what are the roles for your form. For my example I will be using 2 unique roles -Administrator and Business Analyst- and 1 default role that is open to all users.

For each of my unique roles I will need to create a custom list in SharePoint that utilizes the title column to store the usernames of people that belong to this role. I will then populate the lists with a couple of usernames in the format of “domain\username” all lower case (this important). See my example for the administrators role:

Another list was created for the Business Analyst role as well:

Now that i have my role lists set up the next step will be to create the form.

  1. Start with a blank form and add 3 sections to the form. Name them based on the roles.
  2. Next populate the sections with what ever controls you want to be available to that role.
  3. Next we will set up our Data Connections for the Administrator list by going to Data tab> Data Connections and clicking Add
  4. select Create a new connection to Recieve data, click next
  5. select “SharePoint library or list”, click next
  6. Enter the location of your site that hosts the lists and click next
  7. select your Administrators list, click next
  8. check off the title field selection box, click next, next
  9. Enter the Name you want for the data connection, list name is default, then click finish.
  10. Repeat steps 3-9 for the Business Analyst role and any other roles you have
  11. Next you need to add the data connection for the GetUserProfileByName webservice (http://<Your Site>/_vti_bin/UserProfileService.asmx), see my last post on how to do this https://brenthafnersblog.wordpress.com/2012/05/09/auto-populate-infopath-people-pickers/

    Next we need figure out who is logged into the form
  12. Add a textbox to the administrators section called currently logged on
  13. Set the value of the currently logged on user by using a form load rule
    1.  Go to Data Tab > Form Load > New Action
    2.  The condition should be left to None
    3.  Click Add beside the Run these actions, and choose set a fields value
    4.  For the field select your “CurrentUser” text box from the administrators section and for the value use the formula link ƒx
    5.  click insert function and select translate from the text category.
    6.  double click the first field of the translate function and select from the drop down your “GetUserProfileByName (Secondary)” data connection, and expand the dataFields node all the way down to Value.
    7. Select Value and click Filter Data, then click add.
    8. For the first value of the filter condition choose select field or group, and select “Name” from the PropertyData category of your “GetUserProfileByName” data source.
    9. set the condition to is equal.
    10. for the third field insert the following text “AccountName”
    11. click ok, ok to get back to your original translate function for the next 2 fields insert the following “ABCDEFGHIJKLMNOPQRSTUVWXYZ”, “abcdefghijklmnopqrstuvwxyz”. (This will ensure usernames come out in all lowercase)
    12. your formula should resemble the following:

    13.  click ok, ok to finish with your form load rule.
  14. Now that we know who is currently logged on the last thing will be to compare that user to our list of admins and business analysts to determine if they are allowed to see the corresponding sections.
  15. Start by selecting the business analyst section and clicking New Formating in the “manage rules” panel. Then click “None” under the Condition.
  16. For the first field choose “select a field or group”, then choose your BusinessAnalysts data source (SharePoint List).
  17. Expand the dataFields node all the way down and highlight Title.
  18. Under the select drop down choose all occurrences of Title
  19. click ok and choos “are not equal to” for the operator field
  20. for the second field select your CurrentUser field from the administrator section
    Your condition should look like the following:
  21. The last step for this formating rule is to select Hide Control check box since we only want Business Analysts to see the form.

Finally once you repeat steps 15-21 for the Administrators role you should be good to go.

Going forward whenever you need add users to a role you merely need to add the user to the corresponding SharePoint list. See what a user would see if they have been added to the Business Analyst list.

We have now just completed a browser ready form with a workaround to setting up User Roles.

Auto Populate InfoPath People Pickers

There are plenty of times in which you will want users to pick a person from a people picker for your forms however it is not immediately apparent how to have a people picker field auto populated with the user who’s opening the form. I thought I would give an example of this.

First it is assumed that you will be creating a browser enabled form for SharePoint 2010. This still works for regular forms however you need the SharePoint environment available.

I’ll start by creating a data connection to the SharePoint UserProfile web service:

  1. Click the Data Tab > Data Connections > Add
  2. Select Create a new connection to: Recieve data, click Next
  3. Select Soap Web Service, click Next
  4. Enter http://<Your Site>/_vti_bin/UserProfileService.asmx, click Next. see http://msdn.microsoft.com/en-us/library/ee705814.aspx for a listing of available SharePoint 2010 web services.
  5. Choose GetUserProfileByName, click Next, Next, Next
  6. Name the data connection to something useful to remember GetUserProfileByName is Default, then click Finish

Now that we have our data connection set up, now its time to add the people picker.

  1. Click the Home Tab then under controls double click the Person/Group picker to add it to the form.
  2. You’ll notice in the fields section that a people picker is in fact a group with 3 fields in it. (if you don’t have the fields section open this can be done by going to the data tab > show fields)

    Next we need to set default values to these fields
  3. right click DisplayName> click properties > then click the ƒx button under default value
  4. click Insert Field or Group, Then from the drop down select the new data connection you created (GetuserProfileByName)
  5. Expand the dataFields node all the way down through to the values node (see below) and highlight “Value”
  6. with the “Value” field highlighted click Filter Data…
  7. Once the Filter Data window pops up click add… to add a new filter to specify the filter conditions
  8. For the first value of the filter conditions select “Select a field or group…” and then choose Name of your GetUserProfileByName Data Source and hit ok
  9. For the condition make sure it is set to “is equal to”
  10. for the second value choose type Text and put “PreferredName” and hit ok, ok, ok, ok, ok.
  11. Next you will need to do a simlar thing for the people picker AccountId field (Repeat steps 3-9)
  12. for the second value, this time choose type Text and put “AccountName”. For a listing of what properties are available by the GetUserProfileByName Webservice check out Martin’s Blog: http://www.martinsvendsen.com/2009/01/getuserprofilebyname-profile-properties.html
  13. Finally the last field you need to populate is the AccountType. This one you only need to set the default value to “User”.
  14. You can verify that it works by previewing the form before uploading to SharePoint. Remember for people pickers you need to specify the SharePoint Server in the properties section by right clicking the “Person/Group Picker”

Now you can autopopulate the people picker field when someone opens the form. Remember if you want the people picker to retain the information of the first user who opened the form uncheck the “Refresh value when formula is recalculated” box of the DisplayName and AccountId field properties.