Skip to main content
Laura Rogers @WonderLaura

Laura Rogers @WonderLaura

Go Search
SharePoint911
Our Services
Training
Our Team
About SP911
Important Links
SharePoint 2010
Contact Us
  

SharePoint911 > Blogs > Laura Rogers @WonderLaura > Categories
InfoPath User Roles in Browser-Based Forms- Another Way (Part 1 of 2)

This blog post applies to both InfoPath 2007 and 2010, and both SharePoint 2007 and 2010, in MOSS and SharePoint Server 2010 (not WSS or Foundation).

There’s a concept in InfoPath called “User Roles”.  You can set up these roles, and when a person opens theimage form, the form knows if they belong to a certain role, and you can set up certain objects to hide or show in the form based on the user’s role, or switch to a view based on a role, etc.  Each role that you set up can be defined by specific user names, Active Directory groups, or a person’s name from within the form, like this:

UNFORTUNATELY, there are a couple of limitations of this functionality in InfoPath. 

  • User roles are NOT available when creating browser-based forms.  Therefore, if your form absolutely requires these, then all users who ever fill out this form will need to have the InfoPath software installed on their computers.  This is a huge limitation in a lot of cases.
  • User roles cannot be created based on SharePoint Groups, only AD groups.

 

There’s a blog post out there, that describes a a way to get around this limitation, and emulate user roles in a browser based form.  BUT this method entails manually keeping up a separate SharePoint list where you define all of the users and their roles. 

Today, I’m going to tell you about another way of using the currently logged in user’s information instead of roles, and this can be used in a browser-based form.  This can be used with SharePoint groups, where the built in user roles cannot.  The trick is a built in SharePoint web service called the user profile service.  Lori Gowin blogged a while back about how to use this web service in order to auto-populate text boxes in any SharePoint form, with information about the current logged in user.  My method entails using that same web service.  Clarification: This doesn’t refer to ANY SharePoint group, this is only the “members” group that exists on each SharePoint site.  There is another web service that can be used, UserGroup.asmx, in order to get the info about SharePoint groups in general, on a site.

There are a couple of very useful operations in the UserProfileService.asmx web service, so I’ll show you a couple of options (2 parts to this blog).  In this example, you have a change request form.  Site visitors fill out the form, and after they’ve filled it out, people in the IT department will have additional fields to fill in.  We don’t want non-IT staff to see these additional fields, though.  We will create another view in the form.  This view will contain all of the original fields that were filled in by the originator, plus the additional IT fields.  When the form is opened, we want it to automatically switch to this IT view when the logged in user is an IT person.  The prerequisite is that there is a SharePoint group on your site called IT Group, and you are a member of it.  Also, you’ll need a form with 2 views, one of them called IT Dept.

  1. Create a new data connection in the InfoPath form, to receive data.  The source is a web service.  (In SharePoint 2010, pick SOAP web service.)  Click NEXT.
  2. Type the URL of the userprofileservice.asmx file.  This is at the root of your SharePoint site, under the _vti_bin folder.  Click Next.
    image
  3. For the operation, click GetUserMemberships, and click NEXT.
    image
  4. On the Parameter screen, just leave the default and click NEXT.
  5. Leave “store a copy of the data…” unchecked, and click NEXT.
  6. Leave “Automatically retrieve data when form is opened CHECKED, and click FINISH.
  7. Now, when someone opens my form, I want the form to automatically switch to the IT view if the user is in a SharePoint group called “IT Group”. 
    • In InfoPath 2010, click the Data tab in the ribbon, and click the Form Load button, which will bring up the Rules pane on the right.
    • In InfoPath 2007, click the Tools menu and choose Form Options.  Click the Rules button on the Open and Save section.
  8. Define the rule as so:
    The condition is: Click the first drop-down box (the field name).  Click “Select Field or Group”.  In the drop-down for the data source, select GetUserMemberships, which was the first data connection that you created.  Expand several levels and select the DisplayName field.  Click OK.
    image
  9. For the value, click “type text” and type IT Group, as so.  Click OK.
    image
  10. Click to add the Action.  The action will be just to switch views.
    image
  11. The action is just to switch views, so you’re done with the form open rules now.
  12. Now try it out.  Publish the form.  If you’re a member of the IT Group (SharePoint group), the form will now automatically switch to the IT Dept view when it opens.

Stay tuned for part 2 of this blog post, for another way to go about accomplishing something similar with this same web service.

Testing:  This GetUserMemberships operation returns a list of all groups that the current user is a member of, SharePoint and Active Directory.  In order to see exactly what is returned from this operation, here’s how you can do this.  In the data source pane on the right side of InfoPath, click the Main drop-down box at the top of it and change the data source to GetUserMemberships.  This will show all the fields.  Expand several levels until you get to the one called MembershipData.  Drag this whole group of fields onto your form, as a repeating table.  Preview your form.  This will show you a list of all the groups that you are a member of.  You may need to increase the width of the Display name field, so that you can see all the values.  You’ll also notice that there is a field called Source that shows whether each one is a SharePoint group (“SharePointSite”) or a Distribution list.

SharePoint 2010 – Dynamic Calculations in a List Form

In SharePoint lists that contain calculated columns, you may have noticed that when a new form is being created or edited, the results of calculated columns do not display in the form itself, so the user does cannot see the result of the calculation until after they have saved that item.  The calculated field can then be seen as a column in the list, or can be seen when viewing the display form of the item. 

Now in SharePoint 2010 and InfoPath 2010, there is the ability to customize any SharePoint list with InfoPath. Because of this capability, you can dynamically display the calculated results in the form AS the user is filling it out! 

In this example, there is an “Expenses” list with a sales figure for each type of expense for a trip. There is a calculated column, called Total, which shows a sum of all expenses for the trip.

Here’s how:

1. This is the “Total” calculated column in the list:
clip_image002

2. Create items in the list, and notice the calculated field in the display form:
 ch7[1]

3. In the SharePoint list, on the List tab of the ribbon, click the Customize Form button, which will instantly convert the SharePoint list form to an InfoPath form. Click the Quick Publish button in the toolbar at the top left of InfoPath. ch7[2]

4. Notice that now when viewing the form, the calculated field does not display at all:
 ch7[5]

5. Click the “Customize Form” button again. Add a new row to the bottom of the table in the InfoPath Form. From the “Insert a field” panel on the right, insert the “Total” field into the table. Right-click this field, and choose “Calculated Value Properties”. Change the format to decimal and currency and click OK.

6. The trick now is that we want the formula to be dynamically calculated as the currency fields are being filled out. Double click to select the Total field, and click the Default Value button in the ribbon in InfoPath:
 ch7[7]

7. On the Field or Group properties box, click the Function (Fx) button next to the Default Value box.

8. Use the Insert Field or Group button to insert the fields to re-create the same formula that exists in the calculated column, as so:
clip_image012

9. Click OK, leave the box checked that says “Refresh value when formula is recalculated”, and click OK again. Quick Publish the form again.

10. Now, when viewing the form in the browser, you’ll see the total field displayed, AND when filling out a new item, the total will be calculated AS the form is being filled out, which will look something like this:
 ch7[8]

Now you’ll not only be able to work-around the bug in which calculated columns aren’t included in InfoPath forms of SharePoint 2010 lists, you’ll be able to make the calculations dynamic in the form.

 

 

SharePoint 2010 InfoPath List Form – A Fix

In SharePoint 2010 (Beta), a SharePoint list can be created, and a InfoPath form can be quickly created as an interface to the list, instead of using those default forms that aren’t very easy to customize.  I was at a client site last week, teaching SharePoint 2010, and we noticed an issue with the InfoPath form once it has been created.  It is missing those standard fields “Created”, “Created By”, “Modified” and “Modified By” that usually show on a list form.  In this blog post, I will explain the issue I’m referring to, and show you how to fix it.

This is what a non-customized SharePoint 2010 list form looks like:

NEW

ch19[4]

DISPLAY

ch19[2]

EDIT

ch19[3]

Notice the extra “Created” and “Last Modified” information at the bottom of the Edit Form and the Display Form, but NOT on the New Form.  These fields do not exist on the new form, because there is no data for them until after the item has been created.

The problem is that when you convert this list form into an InfoPath form, you lose the Created and Last modified information at the bottom, as so:

  1. In the list tab of the ribbon, click Customize Form: ch19[5]
  2. Click the Quick Publish button in the toolbar at the top, the little lightning bolt: ch19[6]
  3. After the form is published, close InfoPath.
  4. Try opening, editing or creating new forms in the list, and you’ll notice that they are now InfoPath forms, BUT with that Created and Last Modified info missing, as so:

ch19[7]

It is easy to add the missing fields to the InfoPath form, but they need to be configured so that they are not displayed on the NEW form.  Insert a section in the form, and put the 4 fields in there, and set conditional formatting so that the section is not displayed when the ID field is blank.

Here’s how to do it:

  1. Click to Customize Form again.
  2. In the InfoPath form, insert a section at the bottom of the form, and type the text as seen in a default list item view, like this:
    ch19[8]
  3. Insert the proper fields from the Fields pane on the right, so that the section looks like this:
    ch19[9]
    (The field names that I inserted are “Created”, “Created By”, “Modified”, “Modified By”
  4. Select the section, by clicking the word “Section”.  Now the rule can be applied, for the conditional formatting.  Click Add Rule in the ribbon.  Create a new rule so that if the ID field is blank, the whole section is hidden.
    ch19[10]
  5. Click the Quick Publish button again, close InfoPath, and now take a look at the form’s behavior.  Now the New Form will not display that section at all, and Edit and Display forms will show the appropriate information.  Done.

 

Word 2007 Integration Tidbits

Today when I tweeted about the ability in Word to visually compare multiple versions of a document, I was surprised at the number of people who weren’t aware of this feature.  So, this post is a quick step-by-step on a couple of cool things you can do with SharePoint 2007 and Microsoft Word 2007 integration.

  • Compare versions
  • Built in site columns related to Office files

Versioning

When versioning has been turned on in a document library’s versioning settings, you have the ability to not only view a list of versions from SharePoint in the browser, but you can view versions and visually compare them from within Microsoft Word 2007 and 2010.  Here’s how:

  1. Open a Word document that exists in a SharePoint document library with versioning turned on.
  2. Click the <Review> tab in Word. (in the ribbon at the top)
  3. Click the Compare button.
    image
  4. See that there are multiple options at this point.  You can not only compare versions to each other, but you can COMBINE revisions from multiple versions… into one single document.
  5. Click the <Specific Version> button.
    CropperCapture[46]
  6. See the list of versions, which is the same list you’d see from SharePoint. 
  7. Click the <More> button at the bottom, to get even more options.  You can compare WHAT in the documents gets compared!
  8. Click to select a previous version, and then click the <Compare> button.
  9. Now you’ll see the two documents side-by-side, with a list of all the differences.  If you don’t see both on the screen, click the <Show Source Documents> button in the ribbon.

Default Document Site Columns

When looking at the list of default site columns in a SharePoint site, you may have noticed some in a group called “Core Document Columns”.  Here’s how you can put a couple of those (Author & Keywords) to use, and how they inherently integrate with Office files!

  1. In a document library, go to Document Library Settings
  2. Click “Add from existing site columns”
  3. From the “Core Document Columns” group, select Author and Keywords, Add them to the right, and click OK
    CropperCapture[47]
  4. What does this do?  Try it out.  Upload a new document to the library.  Check it out, the Author field automatically defaults to the name of the person who originally created the document in Word. Click OK.
    CropperCapture[48]
  5. What about the keywords?  Next step is to go ahead and open the file in Word, in edit mode.  Click <File> and <Save As>.
    CropperCapture[49]
  6. See in the above screenshot.  There’s the “Tags” text box.  Type a couple of keywords in there, separated by semicolons, and click Save.
  7. Go back to the document library in SharePoint.  Notice that the keywords field is now filled in with the tags that you added in Word.

If you’re not familiar with this whole “tagging” thing, it’s definitely a concept that you’ll see more and more of, especially in SharePoint 2010.  May as well start using it in 2007, and ramp up!  ;-)

 

Social Connector in Outlook 2010

This blog post is about the Social Connector in Outlook 2010 Beta, as it works with SharePoint 2010 Beta and Exchange 2010 Beta.  I just wanted to quickly share with you a couple of discoveries of mine as I play with these products.

Environment:

  • SharePoint 2010 and Office 2010 are installed on one server, which is also the domain controller
  • I’ve installed Exchange 2010 on a second server, and went into group policy and set it up so that it allows everyone to log in locally.  (so I can take turns logging in as pretend users)
  • Several pretend “Contoso” users have been created in Active Directory, and their profiles have successfully been imported into SharePoint 2010.
  • I’ve logged into SharePoint as each of these pretend users, and filled in some profile information, and went through a test Team Site and tagged items, rated items, and made Note Board notes.

In Outlook 2010, there’s a Social Connector that lets you connect to your SharePoint environment.  When you select an email, at the bottom of the screen, there are a couple of little icons of gray people.  CropperCapture[66]  Click that little arrow thingy, and it will expand the People Pane

Then, click the Add button, as seen here:CropperCapture[67]

This will bring up the screen where you can add social network accounts.  Currently in this beta version, it appears as though SharePoint 2010 is the only option.  I added the URL to my test environment:  http://moss In the future, I believe there will be more options in here, such as LinkedIn and Facebook, etc.

Anyway, the main cool thing I wanted to show you today, is the Newsfeed that I discovered in Outlook 2010.  I noticed that listed immediately after my Junk Email folder on the left side, there is a folder called Newsfeed.  So I clicked on it to see what the heck it was. 

THERE is the newsfeed of all of the activities that I’m following on my MySite in SharePoint!!  Your profile on your MySite in SharePoint 2010 lets you follow all of the following activities.  Hmmm, I thought the only place the followed activities were displayed was the My Network page on the MySite.  Apparently this feed is in Outlook also.  Bonus!

This is what it looks like, and you can click the image to get a closer look:

CropperCapture[65]

This is the “Molly Clark” mailbox on the Contoso domain.  I clicked News Feed on the left.  This feed lists all of the activities that Molly is following.  When I click on an item, the reading pane shows me the following:

  • A user named Sean Chai rated a document with a 4 of 5
  • There is a link to the document, which is called “Test Move.docx”
  • People Pane: Since Sean has uploaded a picture of himself on his MySite, this picture is displayed here.

The little green plus under Sean’s picture allows you to add him to one of your social networks.  The Office icon is a link directly to his MySite.  Each time you receive emails in your inbox, you’ll be able to use the plus icon to add people who aren’t already in your social networks.

 

Setup a Data Connection Library, no code required

Mark Miller of http://www.endusersharepoint.com and I did an Excel/SharePoint online webcast, and one of the things that we covered was how to set up a data connection library for people who only have WSS, and don't have MOSS or Excel Services.  Here's a link to a quick recap that Mark did, after our session:

http://www.endusersharepoint.com/?p=1463

Technorati Tags: