Using The expression option and XPath statement for comparing two values in InfoPath 2007 Condition statement

January 18th, 2008 by mlotter

In the post Using InfoPath 2007 Translate function to do what XPath lower-case function does I talked about how to use the “translate” function in a XPath expression box and today I just wanted to continue down the path of using XPath expression box and XPath to compare two values in a Condition statement. In a normal circumstance this would be a very easy thing to do because you would just go select the two fields you want to compare and boom you're done but what if the two field values are not always the same case. Then what do you do? How do you make everything the same case for both fields? This is a situation that I ran into not long ago and below is how I went about solving the problem.

Whenever building a condition statement you only have the options of choosing an existing Field, Group or “The expression” for the first dropdown list and in normal circumstances this would be fine. In normal circumstances if I wanted to compare two values and they were not fields already in the data source and they would not be visible fields then I would create a new Group called “HiddenFields” and then add the fields to that group and populate them in an opening rule. An example of the condition statement that I'm talking about is below.

This works great if all you want to do is a simple comparison and the field values will always be the same text case. As I stated above what if you run across a situation when the text case is going to be different in each field but you still want to compare. You might be thinking that you can use the "Use a Formula" option for each field but unfortunately the "Use a Formula" option is only available for the third dropdown. Below you can see what options are available for each dropdown.

After looking at the pictures you might have noticed you don't have all the selections available in the first dropdown list that you have in the third one. You're probably thinking that this is going to be very difficult to accomplish but in all actuality it's pretty simple if you use the "The expression" option.

When using the "The expression" option there are a couple of things that you can do to make your life a lot easier when building the XPath statement. If you first build the formula for the third dropdown list before changing the first dropdown list to "The expression" then it will copy everything you did into the XPath statement. I usually set the second and third dropdown list values before switching to "The expression" option in the first dropdown list. If you do it this way then you should get something like the below image when you switch.

The formula should look like this.

. = translate(my:HiddenFields/my:Field2, "ABCDEFGHIJKLMNOPQRSTUVWYXZ", "abcdefghijklmnopqrstuvwyxz")

The formula is now 2/3 the way done and now all we have to do is build and add the formula for the first field. The easiest way to do it for this example since the fields are in the same "Group" is to copy the current formula and replace the "." with it and then change the "my:Field2" text to "my:Field1". You might be saying that field box is too small and you wish you had more room to view the formula. If that's the case then open "Notepad" and do all you're editing in there and then paste it back into the field when you're done. At the end the condition box should look like the image below.

The formula should look like this.

translate(my:HiddenFields/my:Field1, "ABCDEFGHIJKLMNOPQRSTUVWYXZ", "abcdefghijklmnopqrstuvwyxz") = translate(my:HiddenFields/my:Field2, "ABCDEFGHIJKLMNOPQRSTUVWYXZ", "abcdefghijklmnopqrstuvwyxz")

Having the flexibility to add a formula to your fields when you compare them should open your world to a lot of new options.  Well it's time for me to get back to work and start preparing for my next gig that starts next week.  I'm pretty excited about this one because it sounds like I'll be doing a lot of cool SharePoint development work.

Cheers

Code Camp and User Group presentations and code projects

January 14th, 2008 by mlotter

Over the last few months I've spoke at 4 different events and have really enjoyed myself but I hadn't got around posting my presentations and code projects because other things kept me busy and I kept forgetting to.  This week I'm at home finishing up some code projects and have found some extra time to spend on my blog and catching up on other things.

Today I got around adding a new page to my blog for the presentations and code projects and just a few minutes ago uploaded all my presentations.  You can find them at /mdlotter/pages/code-camp-and-user-group-presentations.aspx and later this week I'll add my code projects to.  I've really enjoyed speaking at these events and meeting a lot of new people.  I'm hoping that I'll have a lot more entries on this page this year and mean years to come.

Cheers

Visual Studio 2008 VSTO and InfoPath 2007 error when trying to run debug

January 13th, 2008 by mlotter

On Saturday when I was adding my finishing touches to my demo for the Philly Code Camp I ran into an error with Visual Studio 2008 VSTO and InfoPath 2007. Whenever I tried to run my InfoPath 2007 form in debug mode I got the following error.

"Microsoft Office InfoPath does not recognize some or all of the command line options. Exit and restart Microsoft Office InfoPath with the correct command line options"

When I discovered this error and found out that it happened with a brand new project my heart started to beat a little faster (ok lot faster) because I knew the pressure was on to fix the problem before my session started. I started to do searches on the internet and I couldn't find any answers and then I did one final search and I found some link that talked about a similar error with Visual Studio 2008 Beta 2 and another office application. It mentioned about updating Office 2007 with a patch to fix the error. After reading that I looked at the version I was running and notice that I wasn't running SP1 for Office 2007 and decided to install that and see if it would fix the error. Luckily I had internet access at the code camp and started the download and about 30 minutes later I got it downloaded and installed. Then I crossed all my fingers and toes and tried the debug mode again and it worked. By installing SP1 for Office 2007 fixed the problem. I'm sure there will be many more little things pop-up and if I run into them I'll be sure to post them.

By the way Philly code camp rocked the house and I'm glad that I got a chance to speak.

Cheers

Speaking at Philly Code Camp on January 12th

January 5th, 2008 by mlotter

The Philly.Net Code Camp is coming up on Saturday, January 12th at DeVry University in Fort Washington, PA and I'm happy to say that I will be giving a presentation at the event.  The presentation is titled "InfoPath 2007 with Visual Studio 2008".  The session walks through building a new InfoPath 2007 form, Web Service, .NET Class, Workflow and LDAP query with Visual Studio 2008.  The form will call the web service on opening to retrieve the current user Active Directory information and State list from SQL 2005 database to populate an InfoPath form drop down list.   A simple workflow will be created and deployed with Visual Studio 2008 for sending an email.  This presentation will cover more details than what I usually do and it will all be using Visual Studio 2008 and not 2005.  Information on attending and a list of all the tracks for the code camp can be found at http://www.philly.net.

In my opinion the Office track is jammed pack with great sessions and we have Bob Fox doing a session on SharePoint Disaster Recovery and Backup (Wow can't what to see what type of code Bob has).  A full list of all the Office sessions is listed below.

David Mann – Delivering Modular SharePoint Workflow Functionality via Components
Bob Fox – SharePoint Disaster Recovery, Backup and more…
Tony Testa – AJAX in SharePoint
Michael Lotter – InfoPath 2007 with Visual Studio 2008
Russ Basuira – Programming Composite Applications that use the SharePoint Business Data Catalog
Gary Blatt – Using OpenXML to Access Excel and other Office 2007 Files

I'm really excited about this opportunity because it gives me another opportunity to meet new people and to work on my speaking and presentation skills.  The last 2 code camps were a blast and I'm sure this one will be to, please come out and join us for a great time talking about writing code (things we love to do) and meeting new people.

Cheers

Happy Holidays!

December 25th, 2007 by mlotter

Just wanted to wish everybody the best over the holidays.

Cheers

Using InfoPath 2007 Translate function to do what XPath lower-case function does

December 19th, 2007 by mlotter

Several days ago Joe and I found ourselves wanting to make sure we made the InfoPath “UserName()” function return all lower case characters and we decided to use the common XPath function “lower-case” but was surprised because it didn't work. With a little research I found that we could use the InfoPath “Translate” function instead. I must say that it's a little frustrating that some common XPath functions don't work and you have to find the work around but if you do any InfoPath development you come accustom to it. Below is what we tried that didn't work and what we did that did work.

What didn't work: lower-case(xdUser:get-UserName())

What did work: translate(xdUser:get-UserName(), “ABCDEFGHIJKLMNOPQRSTUVWYXZ”, “abcdefghijklmnopqrstuvwyxz”)

Basically for “Translate” we had to specify every letter in the alphabet in UPPERCASE and then lowercase to make sure every character will get translated. For more information on “Translate” checkout this link http://office.microsoft.com/en-us/infopath/HA012330391033.aspx and do a search for “Translate” for the official description (It's towards the bottom of the page).

If you foresee yourself using this more often then something to consider is creating a “Template Part” for this. It would be very simple because it would have two fields one called “translate_uppercase” and another “translate_lowercase” and each field default value would be the alphabet in the correct case. Then whenever you would want to use the “Translate” function you would add the “Translate Lower Case Template Part” to the form and build the expression as translate(fieldname, translate_uppercase, translate_lowercase). This would be a lot simpler than typing in all those letters and if you have more than one person doing InfoPath development it would create a standard way of doing it.

Cheers

Using the iisapp command to get the Process ID for the correct w3wp process for Visual Studio debugging when doing SharePoint, Workflow or InfoPath development

December 16th, 2007 by mlotter

I'm sure this is posted in a 100 different spots but I just learned about it before I went on vacation and wanted to share it.  It has never really bothered me at guessing which w3wp.exe process to use for debugging SharePoint code but when I was working with Joe (new guy) he saw what I was doing and he told me there was a lot easier way of identifying the w3wp process.  He said just open a command prompt and type in "iisapp" and it will list all the Application Pool processes with the process ids.  I took his advice and sure enough it gave me everything I needed to choose the correct process from the Visual Studio "Attach to Process" screen.  If you don't really know what I'm talking about then below is details on how to do it.

For me there are times when I'm developing with InfoPath or SharePoint and I need to create some code (Workflows, Web parts, …) that runs part of the w3wp process and running it in debug mode from Visual Studio is not possible and you will have to deploy the code and then attach the Visual Studio project to the w3wp process that its deployed for stepping through the code.  For example, recently I had to create a new SPD Workflow Action to send out emails with a "From Address" that can be specified and to use the SharePoint SMTP property that's set in Central Admin.  To do this I had to create a new Workflow Activity Library project and this project type can't be run in debug mode from Visual Studio (if I'm wrong about this please correct me).  To debug the code in this project you have deploy it first and then attach your Visual Studio project to the w3wp process that it runs in and then do something from SharePoint or InfoPath that will execute the deployed code.  To attach the Visual Studio project to w3wp process you can either click "Debug->Attach to Process" or "Tools->Attach to Process" menu combination and then the "Attach to Process" screen will appear.

Then you will need to select the w3wp process that your code is running in.  If you develop on a SharePoint server then you will almost always have more than one w3wp process to choose from.  This is where the "iisapp" command helps out.  If you open a command prompt and type "iisapp" then it will list all w3wp process (Application Pools) running with some details.

This list should give you enough information to choose the correct w3wp process from the "Attach to Process" screen.  Click the entry you want and then click to the "Attach" button to attach to it.  Now set your break point and then do something from SharePoint or InfoPath that will execute the code.

I'm sure this was a big repost for most people and I'm sorry for that but I just wanted to share what I learned that way it may help someone starting out with SharePoint, Workflow or InfoPath development.

Cheers

NJSPUG Meeting Details for December 19th

December 16th, 2007 by mlotter

The NJSPUG has launched a new website at http://nj.sharepointgroups.org/default.aspx and all the details and future details of user group meetings can found here.  As I previously mentioned that I'll be speaking at the December 19th meeting and all the details are below.  Hope to see you there.

NJ SHAREPOINT USER GROUP: 

Wednesday, December 19

 https://www.clicktoattend.com/invitation.aspx?code=121800

  Creating InfoPath 2007 forms with InfoPath Forms Service for the enterprise

 

Guest Speaker: Michael Lotter MCP, MCTS

SharePoint Solutions Architect |

B&R Business Solutions, LLC

"With the new version of SharePoint and InfoPath being officially released this year the concept of building and using e-forms in the enterprise has officially become a reality by using InfoPath 2007, InfoPath Forms Services and SharePoint 2007 Enterprise.  This presentation will describe how to use InfoPath 2007 and InfoPath Forms Services (part of SharePoint 2007 Enterprise) to accomplish this with your existing or new SharePoint 2007 Enterprise installation. A demo will be given to show how to build and publish an InfoPath 2007 form to InfoPath Forms Services and how to active the forms from InfoPath Forms Services to a Site Collection."

 AGENDA:

5:30 PM EAT + GREET
Networking, Free Food/Drink

6:00 PM Guest Speaker

"Creating InfoPath 2007 forms with InfoPath Forms Service for the enterprise"

6:45 PM  WRAP UP
discussion, prize giveaways

 

Back from vacation

December 16th, 2007 by mlotter

Heather and I just got back from a 2 week vacation in Dominican Republic and we had a great time. Heather wanted to stay longer but I was ready to get back and somehow convinced her to get on the plane for home. I'm not that much of a beach and ocean person but still had a great time do to the friendly people at the resort in Punta Cana and citizens of Santo Domingo. We only stayed 4 days in Santo Domingo and were unable to see everything but hopefully will have a chance to go back in the coming years to see everything else. Heather and I took some pictures while we were on vacation and when I get a chance I'll upload them to the net.

Cheers

Great time at the Nova Code Camp

November 26th, 2007 by mlotter

The Nova Code Camp has come and gone and so has the Thanksgiving holiday.  Nas and I had a great time at the Nova Code Camp and we can't wait for the next one. It was a really good code camp for me because I got to meet some great new people and my session seemed to go really smooth and I have spotted some new areas where I can approve my code demo. The whole code camp thing is still really new to me and before going to them I was fearful that I wouldn't enjoy them but so far I've been totally wrong. Speaking and attending these code camps have given me the ability to open my mind and view things differently. It has also given me a new perspective on InfoPath and SharePoint and how to approach and tackle problems that I have in the work place. Overall it has been a great experience and I can't wait to continue down this path and see what else comes from it. At some point the presentations will be added to the http://novacodecamp.org/ website and if you have any interest in what happened I would definitely go check them out.

While at the code camp I got to meet Jeff Schoolcraft (http://thequeue.net/blog) the guy that organized the event and we had some great conversations about many different topics. During one of the conversations he mentioned http://www.community-credit.com/ website and I told him that I never heard of it before and he said that I should check it out. The next day I did and I must say that it's a pretty interesting site and I thought it was worth passing along.

Since the Nova Code Camp is over I've started getting ready for the NJ SharePoint User Group meeting that I'll be speaking at in December. The presentation will be a little different than the code camp presentation because I was told that I should focus more on slides and content then code but I'll still be talking about InfoPath, InfoPath Forms Services and SharePoint. Once I get the official date and time from either Jason Medero or Bob Fox then I'll pass it along but I do know that it's in the third week of December and I'm pretty sure it's on Wednesday. Hope to see some of you there.

Cheers