Wednesday, January 30, 2013

InfoPath 2010/2013: Checking An Account in a Multi-Select Person/Group Picker

When you drag a Person/Group Picker onto your form, the underlying structure is a repeating group as shown here:

You may allow the picker control to contain multiple selections by editing the control's properties:
When you allow multiple selections and you want to create rules based on someone in the list, you must perform the "contains" logic on the group folder. If you just look at the AccountId or the pc:Person folder, the logic will only be "true" if the account you are looking for is the first entry. Performing the logic on the folder that contains the pc:Person repeating group, allows you to include all person/group entries in the checking of a specific account.
This may be used in rule conditions:
Or it may be used in formulas using the contains() function:

You may use this logic to hide/show sections, controls, etc. based on the current user being selected in the Person/Group picker and/or allow additional functionality.


Friday, January 25, 2013

SharePoint 2007/2010/2013: Dynamic Time Zones in Search Results

There is a centralized calendar in SharePoint which contains various events across offices around the world. Each office may have it's own time zone. The user experience is that they should be able to search and filter these events thus involving a search scope and customized search results.

The SharePoint servers are in the Eastern time zone and have that setting. All events are being stored in EST. (UPDATEAll events are stored in SharePoint as UTC. The date/time is then converted to the timezone of the user viewing the event item based on their regional settings at the site collection level - at least in MOSS 2007. Since our service account is EST, we retrieve all times in EST from the web service). A web service queries the events calendar list and produces search results accordingly using custom metadata properties mapped to the crawled web service properties via BDC/BCS.

If all meetings and events are stored as EST, and the web service just returns the start and end times, those times will all be EST. However, since there are offices all around the world, that means there are users all around the world. So the problem is that the search results should display the time of event based on the user who is viewing the events.

Because I was locked into search results already I had to go that route. This could have been easily resolved if I had some sort of MVC application running and use javascript to dynamically calculate the event time client-side.

So instead, I had to modify the the web service to produce the start and end times for each time zone in which there was an office. For example, DisplayStartTimeEST would store the Eastern time, and DisplayStartTimePST would store the Pacific time. I then added all of these new fields to the BDC/BCS definition and crawled the content source. I mapped new metadata properties to the underlying crawled properties of the web service.

In the search results XSLT, I essentially show every time zone within a <div> whose (style) classes match the time zone. The style classes are all set to be hidden.

The style example is shown here:

The HTML in the XSLT looks like the following:

So the only thing left to do is figure out the user's time zone (based on their machine setting) and then show the proper time zone value. To get the time zone, I used the jsTimeZoneDetect code available here. Then I all I had to do is add a javascript function to show the proper <div> based on the time zone that was determined. I placed this code on the search results page via a Content Editor Web Part (since it was SharePoint 2007):

With my machine set to Eastern Time, I saw the search results in EST:

I then changed my time zone to Pacific:

When I refresh the search results, I now see the event time in PST:

My solution is a hack but it works!!! So to wrap up, the solution basically is to bring back all time zones in the search results and then only show the correct one based on the user's time zone setting. Using a different display mechanism other than search results and calculating the time zone on the fly would be a more elegant solution but I had to work with what I was given.


Sunday, January 20, 2013

InfoPath 2013: Using the Unsupported position() Function

When using XPath expressions in InfoPath you may find that position() and last() are not supported. They are not supported in the intended XPath expression usage where you apply the function to a data element to find the position or retrieve the last element. However, the position() function by itself may still be applied to a Calculated Value control to determine the current position of an element in a repeating data structure.

At first it doesn't appear that position() works when you attempt to add a Calculated Value control. Entering position() in the XPath box produces the unsupported message.

Function position() and last() are not supported.
However, if you simply select a field or function that is supported you may click OK to add the Calculated Value control to your form. Then you can edit the Calculated Value Properties:

And enter position() in the XPath:

Clicking OK this time allows the function to be used. This function comes in handy when used with repeating tables to produce a row number or incremental value to each data entry:

So position() is not supported but it is works by itself.


Wednesday, January 16, 2013

SharePoint 2013: Activating Video Support in Your Site Collection

A few weeks ago, I wrote a post on using videos in SharePoint 2013 . However, as a reader pointed out, I did not really explain how to make sure that your site collection was set up to support videos and media. So here it is.

To enable video support within SharePoint 2013, you need to activate the Video and Media feature at the site collection level. Here are the quick and easy steps to perform this activation.

Step 1: From the Settings (gear icon) menu on your site collection, select Site Settings.

Step 2: Click on Site Collection Features under the Site Collection Administration section.
Step 3: Scroll down and find the Video and Media feature. Click on Activate to activate the feature.
Step 4: Return to your site collection. When you go to add an app for Videos, use the Asset Library:

Learn how to embed YouTube videos into your library.
Learn how to link to videos outside of SharePoint.


Wednesday, January 2, 2013

InfoPath 2013: Business Connectivity Services Client Components

Problem: You attempt to use the External Item Picker in InfoPath 2013 and you receive a message and/or error message regarding Business Data Connectivity Services client components and/or the BCSLaunch.dll is missing.

The messages you may receive are as follows:

The current operation requires Business Connectivity Services client components. Install Business Connectivity Services client components and try again.

The program can't start because BCSLaunch.dll is missing from your computer. Try reinstalling the program to fix this problem.
Originally I thought I needed to go to the link in the first message to install client components. That link takes you to Prerequisite software needed to work with external data in Office 2013. As of this writing there were only three (3) downloads. I figured I had the SQL components and obviously .NET Framework 4.0 so I decided to download and install the WCF Data Services 5.0 for OData V3. I thought this made sense since BCS now supports OData connections.

I probably didn't need that but, interestingly enough, after the installation, I received both the original message and then the BSCLaunch.dll is missing message appeared. On a different environment I never received the first message and it just went right to the BCSLaunch.dll is missing error message.

So anyway, the overall solution is a simple fix. You simply need to make sure you add Business Connectivity Services to your Office 2013 installation under the Office Shared Features:

(You can get to here through Control Panel -> Programs and Features -> right click Microsoft Office Professional Plus 2013 and select Change -> click Continue with Add or Remove Features selected.)

Simple use the drop-down to select Run from My Computer:

Click Continue and Office will install the missing components.

After the installation is complete, you should now be able to add an External Item Picker onto your form without and errors or messages:


Matched Content