Add Collapsible Help to InfoPath Forms


One of my favorite things to do in relation to SharePoint is business process automation using workflow. What I REALLY enjoy is developing InfoPath forms to go with the workflows.

Recently I was working on an InfoPath form that had a need for a significant amount of text-based help within the form. If it is a sentence or so, it’s not a big deal to put the text inline or even as a screentip, but this was more text than a sentence.

After some thinking and playing with rules and picture buttons, I came up with the solution below:

Help collapsed, notice the [?] icon:

Help expanded, with a different [-] icon:

Create a PerformancePoint Service Application Database without GUIDs


There are many resources out there for creating the majority of SharePoint 2010 Service Applications using PowerShell. This gives you more control in terms of defining clean database names. One specific application that I have yet to find a legitimate answer for is the PerformancePoint Service Application.

Some people have suggestions on how to rename the database in SQL Server and then run a Set-SPPerformancePointServiceApplication command in Powershell. While this seems accurate (and in reality is close), it doesn’t rename the MDF or LDF files.

One of many possible solutions is to do the following in PowerShell:

$performancePointSAName = "PerformancePoint Service" $saAppPoolName = "SharePoint Web Services" 
$newDb = "SP2010_SA_PerformancePoint_DB" 
New-SPPerformancePointServiceApplication -Name $performancePointSAName -ApplicationPool $saAppPoolName 
New-SPPerformancePointServiceApplicationProxy -Default -Name "$performancePointSAName Proxy" -ServiceApplication $performancePointSAName 
Get-SPServiceInstance | where-object {$_.TypeName -eq "PerformancePoint Service"} | Start-SPServiceInstance

This will give you a working PerformancePoint application with a GUID. Next, in SQL Management Studio; backup the existing PerformancePoint database to a .bak file.

Create a new database with a clean name such as “SP2010_SA_PerformancePoint_DB”, restoring from your .bak file. Next, back in the SharePoint Management Shell; run the following command:

Set-SPPerformancePointServiceApplication -Identity $performancePointSAName -SettingsDatabase $newDb 

Warming up SharePoint 2010 using PowerShell


If you’ve been around SharePoint 2007, SharePoint 2010 or just .NET for any amount of time, you know that pages are not compiled until the first time a server request is made to view them. This causes the first load to be the slowest.

There have been numerous solutions for this, most of them are some form of a warm-up script.

In SharePoint 2007, there were a few versions; all of which used the command-line STSADM tool to basically enumerate all sites in a web application and then submit an HTTP request to cache the pages on the server side.

In SharePoint 2010, the STSADM based scripts still work; but why use them? We have PowerShell!

I found some really good examples of PowerShell based Warm-up scripts, but none of them served my purposes or my clients. Since I’m really starting to dig PowerShell, I decided to do my part in the SharePoint community by developing my own version of the SPWarmup script.

#################################################################################
## SPWarmUp.ps1 - Enumerates all web sites in web applications in a SharePoint  #
## 2010 farm and opens each in a browser.  This version does not use STSADM	#
## and instead uses PowerShell.							#
## 										#
## Notes:									#
## -"get-webpage" function borrowed from:					#
## http://kirkhofer.wordpress.com/2008/10/18/sharepoint-warm-up-script/		#
##										#
## Assumptions:									#
## -Running on machine with SharePoint 2010 installed				#
## Although bits and pieces were borrowed from Kirk Hofer and Martin Laukkanen,	#
## The final working version with nice enhancements is courtesy of Ryan Dennis.	#
## www.iccblogs.com/blogs/rdennis - Twitter: @SharePointRyan			#
#################################################################################
  
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

# By uncommenting the following lines as well as lines 54-60 you can warmup other sites such as SSRS #
#$extrasitelistfile = 'c:\warmup-extrasites.txt'

Start-SPAssignment -Global  
function get-webpage([string]$url,[System.Net.NetworkCredential]$cred=$null)
{
   $wc = new-object net.webclient
   if($cred -eq $null)
   {
     $cred = [System.Net.CredentialCache]::DefaultCredentials;
   }
   $wc.credentials = $cred;
   return $wc.DownloadString($url);
}
  
#This passes in the default credentials needed. If you need specific
#credentials you can pass them in to elevate the permissions.
#Or run this task as a user that has a Policy above all the Web
#Applications with the correct permissions
  
$cred = [System.Net.CredentialCache]::DefaultCredentials;
#$cred = new-object System.Net.NetworkCredential("username","password","machinename")
  
$apps = Get-SPWebApplication -IncludeCentralAdministration
foreach ($app in $apps) {
$sites = Get-SPSite -WebApplication $app.url -Limit ALL -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
foreach ($site in $sites) {
Write-Host $site.Url;
$html=get-webpage -url $site.Url -cred $cred;
}
}

## Warm up other sites specified in warmup-extrasites.txt file (such as SSRS)
#if (test-path $extrasitelistfile) {
#   $extrasites = get-content $extrasitelistfile
#   foreach ($site in $extrasites) {
#     write-host $site;
#     $html=get-webpage -url $site -cred $cred;
#   }
#}

Stop-SPAssignment -Global

InfoPath Designer 2010 and SharePoint 2010 are a great team!


In case you’re not as fortunate as me and you haven’t had the privilege of experimenting with SharePoint 2010 and the new Form Templates available in InfoPath Designer 2010, here are some cool things you can do without code!

  1. Create a custom branded User Profile Lookup Form to talk to the UserProfileService.asmx web service. Pull in data such as Preferred Name, E-mail address, Profile Picture, Department, Manager, etc. Put this in an InfoPath Form Web Part and give the user a nice UI for querying your Active Directory.
  2. Create a custom Site Provisioning Form to talk to the Sites.asmx web service. Wrap an approval workflow around it so that when the manager approves the site request it gets auto-provisioned. The user doesn’t need permission to create sites because you can run it with elevated privileges. The manager doesn’t need to manually create the site for the user after approving it; everyone wins!

These are just two of the cool things you can do with SharePoint 2010 and InfoPath 2010.

How to get to the old-fashioned create.aspx page in SharePoint 2010


There may be a time when you need to bypass the fancy shmancy Silverlight create.aspx modal dialog. “Why would I ever want to do that?” you ask? Well, I’ll give you an example:

Perhaps you need to inspect the DOM elements of your custom site template to get its unique ID so that you can create sites based on that template via the SharePoint Web Services in an InfoPath form.

That’s what I needed to do…

Anyways, to get to the old-fashioned create.aspx page, simply type the following:

http://sharepointserverurl/_layouts/create.aspx?IsDlg=0

The IsDlg=0 at the end tells SharePoint not to render the modal dialog and you will end up at the create.aspx page where you can use the Developer toolbar or Firebug to inspect page elements.

Have fun!