Header Image -

Monthly Archives

3 Articles

InfoPath equivalent to @UserName

by dave 0 Comments

Standard disclaimer – the ‘migratenotes’ posts come from a Notes Migration blog that I wrote from 2007-2010.  More Info

——-

So in Notes, popping in a Names field with a default value of @UserName is a very simple, easy action.

In InfoPath? Not so much.

I first had to seek out how to even get a name selection control running in an InfoPath form, and then I discovered that the XML data needed for that control made a simple userName() call ineffective. A plain-text field can easily pull the current user, but not a selection control.

So I spent some google time compiling solutions, and found how to make the control pull the current username. Cool. But the answers I found pulled the name on all form loads, not just the initial load. So I had to get the rule to run only on the first load. Doing field comparisons to only run if my values were blank didn’t work. XDocument.IsNew was not recognized as a valid formula. So I ended up doing another hack with inappropriate XML data to flag what status the document was in.

I’d like a cleaner answer to running a Form rule on initial load only — does anyone have one?

In the meantime, here is the ugly detail that I emailed to my co-workers in case they need to do the same time:

If you want to add a field to an InfoPath form with a name selection from AD, follow instructions here:

http://blogs.msdn.com/infopath/archive/2007/02/28/using-the-contact-selector-control.aspx

These instructions are very simple compared to what it takes to make the current user default into this control.

To do that…

1) Set the required default values:

  • From your Data Source Window:
  • Navigate to your XML data structure that you build for the contact selector.
  • Right-click “DisplayName”
  • Click the “fx” button next to the default value field
  • Enter “userName()” Case sensitive, and you have to enter it via this dialog box, otherwise it is treated as text, not as a function.
  • Also add a new field to your data source, called “IsNew”, text, default value = “1″ (This will be used to be sure the data is only set on initial form load. I tried LOTS of cleaner methods, but this is the only one I got to work reliably.)

2) Make a connection to the SharePoint Web Service to check names against AD:

  • Select “Manage Data Connections”
  • Click “Add”
  • Click “Create A new connection to:”, Select “Receive Data”, Click “Next”
  • Click “Web Service”, Click “Next”
  • Enter: “https://your.sharepoint.server/_vti_bin/people.asmx?WSDL”, Click “Next”
  • Select “ResolvePrincipals”, Click “Next”
  • You will see a list of the data for the Web Service — just click “Next”
  • Uncheck “Store a copy of the data in the form template”, Click “Next”
  • Uncheck “Automatically retrieve data when form is opened”, Click “Finish”
  • Close The Data Connection dialog box.

3) Open the Form options to set up a query to this web service upon open

  • From the main infopath menus, Select Tools –> Form Options
  • Go to the ‘Open and Save’ page\
  • Click “Rules”
  • Click “Add”

4) Set the default value from your Display Name into the Web Service Query

  • Click “Add Action…”
  • Select “Set a fields Value”
  • Click the box next to the “Field:” field
  • Change the Data Source Drop Down to “ResolvePrincipals (Secondary)”
  • Navigate the tree to select “myFields –> queryFields –> tns:ResolvePrincipals –> principalKeys –> string”
  • Click “OK”
  • Click the “fx” box next to the “Value:” Field
  • Click “Insert Field or Group:”
  • Navigate to the XML structure you built for your contact selector – select the DisplayName field
  • Click “OK”, Click “OK”

5) Set the principalType fields for the Web Service Query

  • Click “Add Action…”
  • Select “Set a fields Value”
  • Click the box next to the “Field:” field
  • Change the Data Source Drop Down to “ResolvePrincipals (Secondary)”
  • Navigate the tree to select “myFields –> queryFields –> tns:ResolvePrincipals –> principalType”
  • Click “OK”
  • In the “Value:” Field, enter: “User SecurityGroup SharePointGroup DistributionList”
  • Click “OK”

6) Tell the form to perform the query

  • Click “Add Action…”
  • Select “Query using a data connection”
  • Under Data connection, select “ResolvePrincipals”
  • Click “OK”

7) Set your DisplayName value from the Query Results:

  • Click “Add Action…”
  • Select “Set a fields Value”
  • Click the box next to the “Field:” field
  • Navigate to your contact XML, and select “DisplayName”
  • Click the “fx” box next to the “Value:” field
  • Click “Insert Field or Group”
  • Change the data source to “ResolvePrincipals (Secondary)”
  • Navigate to and Select “myFields –> dataFields –> tns:ResolvePrincipalsResponse –> ResolvePrincipalsResult –> PrincipalInfo –> DisplayName”
  • Click “OK”, Click “OK”, Click “OK”

Set the accountID value from the Query Results:

  • Click “Add Action…”
  • Select “Set a fields Value”
  • Click the box next to the “Field:” field
  • Navigate to your contact XML, and select “AccountID”
  • Click the “fx” box next to the “Value:” field
  • Click “Insert Field or Group”
  • Change the data source to “ResolvePrincipals (Secondary)”
  • Navigate to and Select “myFields –> dataFields –> tns:ResolvePrincipalsResponse –> ResolvePrincipalsResult –> PrincipalInfo –> AccountName”
  • Click “OK”, Click “OK”, Click “OK”

9) Set the AccountType value from the Query Results and close the dialog boxes

  • Click “Add Action…”
  • Select “Set a fields Value”
  • Click the box next to the “Field:” field
  • Navigate to your contact XML, and select “AccountType”
  • Click the “fx” box next to the “Value:” field
  • Click “Insert Field or Group”
  • Change the data source to “ResolvePrincipals (Secondary)”
  • Navigate to and Select “myFields –> dataFields –> tns:ResolvePrincipalsResponse –> ResolvePrincipalsResult –> PrincipalInfo –> PrincipalType”
  • Click “OK”, Click “OK”, Click “OK“

10) Set the Rule to only run on the initial load of the form

  • Click “Set Condition…”
  • In the first dropdown box, select “Select a Field or group”, then navigate to your “IsNew” field that you created earlier.
  • 2nd drop-down = “is equal to”
  • 3rd drop-down, select “Type Text…”, and enter “1″
  • Click “Add Action…”
  • Select “Set a fields Value”
  • Navigate to your “IsNew” field for the “Field: field.
  • Value: 0
  • Click “OK”, Click “OK”, Click “OK”, Click “OK” (Close out all dialog boxes)

Whew! Now you are done and it should work..

———————

Just as a comparison, In Notes:

  • Make a name fields
  • Set the default value to @Username
  • 🙂

Fun with InfoPath

by dave 0 Comments

Standard disclaimer – the ‘migratenotes’ posts come from a Notes Migration blog that I wrote from 2007-2010.  More Info

——-

I’m having fun this week. I’m digging into InfoPath for the first time, as we’re now into some of the more complex forms that really are not readily handled by basic SharePoint lists.

I’ve discovered a few tidbits that I wanted to document here. Please note that I’m a flippin’ newbie when it comes to InfoPath, so some of these notes might be obvious to others, and some of them might be bad ideas and show my inexperience.

InfoPath is an XML-based product. Underlying your forms is (normally) an XML schema. This actually translates very well to Notes data. Notes parent/child relationships between documents mesh very nicely with an XML scheme that includes child document data as a node in the XML.

What this means is that I’ve been able to take multi-form Notes databases, and replace them with a single InfoPath form, published to a SharePoint library.

However, this approach did have a few challenges:

1) User Interface

Putting all that data on one form is a UI challenge. In the two forms I’ve worked on this week, I’ve used tabbed tables. One is your typical tabbed table, with tabs across the top. The other was a very long form (about 30 pages printed), so I created vertical tabs down the left side of the page that act as a table of contents for the form.

There are articles out there on how to do tabbed tables in InfoPath. Go read them to get the idea of what controls you need to lay out, then come back here, because I did it a more efficient way. Instead of using your buttons to switch to a new view, think like a Notes Developer — Use “Hide-Whens”. In InfoPath, it is called “Conditional Formatting”. Create data fields to store which sections should show, and have your buttons set those fields appropriately. Then just set your conditional formatting off those fields, and you have tabbed tables in a single view.

This also has an added benefit that you can create multiple tabbed tables that all operate independently of each other. The view-based solutions online do not allow for this.

“But wait — isn’t that mixing UI data into your XML? That is a horrible thing to do.”

Yes. Yes, it is. First off, relax. We’re already on Microsoft products, so whatever you do is a hack, no matter how clean you make it.    But seriously, I did make an attempt to address this issue. I created a new node in my XML to hold this form metadata. If I need cleaner XML to send this data to another system, I just need to drop that node. And in the meantime, my UI holds its state between form loads.

2) Security

We don’t have authors fields. We don’t have readers fields. We need to make SharePoint security do everything for us, or use pseudo-security via the UI. For SharePoint security, we’re kinda out of luck for Readers/Authors functions, but it can handle most other security needs. For UI security, it isn’t truly secure, but depending on the application needs, it might be secure enough. InfoPath and SharePoint are not like Notes, where a savvy user can edit the document data by making up their own forms and agents, etc. You cannot right-click and see data fields, bypassing the UI. Even for most savvy users, they have to use your UI. So if you, for example, disable all controls in your InfoPath form unless the current user is listed in a specific field, that will actually work more reliably than a similar technique in Notes.  There are still ways around it, but it should be enough of a deterrence to be effective for basic business apps, especially if you have revision history turned on in the SharePoint Library and can throw out any inappropriate edits to your documents.

3) Workflow

InfoPath coding cannot send email notifications. But it does very well at creating buttons that perform different actions. SharePoint workflows are more complex, if they need to perform logic on your InfoPath data, but they can create workflow tasks and emails very nicely. I haven’t yet got all the answers as to what the best practices will be when making choices between InfoPath rules and SharePoint workflows.

For the form I finished today, I did most of the work in InfoPath, then created a SharePoint workflow to handle notifications for the approval cycle.

To make your InfoPath fields available to SharePoint, you must select them when publishing your form. It is hard to miss this step, as the publishing wizard asks you very directly which fields you want to expose to SharePoint. Be sure to expose anything that your workflow will want to read.

If your workflow also needs to set an InfoPath field, there is a checkbox that reads “Allow users to edit this data in a datasheet”, or something to that effect. Select this checkbox. If it is not selected, you cannot set the field with a SharePoint workflow.

If you have multiple fields in your XML data source with the same name, but under different nodes, SharePoint pulls them all in with just the name, and loses your hierarchy. I didn’t delve deeply into how much this would screw things up, I just got a sense of ugliness and decided that I needed a different way to handle things. So I made copies of the data I needed in my meta-node that I used for UI data, and I exposed these copies instead. Is this a bad idea? I don’t know. There may be a cleaner way around this particular problem, but I have not yet learned it.

————————–

In general InfoPath is a nice tool. It will feel more like Notes Form development to us Lotus folk, and provide many of the features we are used to. Much of our design skill and UI experience will translate directly across, and I wouldn’t be surprised if Notes people start becoming very innovative in InfoPath, as we think differently than .NET folks, so we will approach form development with new ideas. I’m looking forward to getting past this phase of learning, and seeing what I can really do with the tools over the next few months.

Under 1000 DBs left

by dave 0 Comments

Standard disclaimer – the ‘migratenotes’ posts come from a Notes Migration blog that I wrote from 2007-2010.  More Info

——-

It may have been quiet on here, but I’ve been busy cleaning up our Notes environment.

And we have hit what I feel is a nice milestone we have under 1000 Notes databases left on our productions servers, and that includes the system databases and others that I know we don’t need to worry about migrating.

Another 500 should be gone at the 1st of the year, and I’mn hoping to enter 2009 with only about 250-300 databases to worry about.

(Of course, some of those 250 are very large, complex, apps.)