Add som nice picture buttons to your form

Hi everyone!

I thought that I should show you how easy it is to spice-up your form with som nice pictures as buttons instead of the boring ones that comes along.

Start by adding a couple of ordinary buttons to your form.

When that is done highlight a button by clicking on it.

In the ribbon, choose the Layout tab.

Then in the Table section, choose the drop down Change to to change the button to a picture button.

Now when that is done open the properties of the button. As you will notice you are given the opportunity to add not one, but two pictures for each button. The second button will act as the a hover-button, isn’t that nice 🙂

If you choose the Advanced tab you could add some text as well that will be shown when you hover over the button.



Expense report (follow-up)

Hi everyone!

Ok, so this is a follow-up on my last post Name of month in expense report.

I promised that I would tell you how I did to get this expense report, to be editable only until a certain date and how the field that is telling us for which month this report is valid for, would keep it’s value even if the report is opened later on.

In this example, let’s say that our finance dep would like the employees to deliver their expense reports prior to the 16 of the current month. The employees should still be able to open these reports later on to be able to check and compare but not being able to make any changes or to save the report.

If you haven’t already created a data connection to submit the form back to the form library and added a button for the users to do this with, please do so 🙂

Set the correct month and keep its value

Now we need to do a few things to keep the value of the field for which month this report is for. What I am taking about is the field right after the title.

Start by adding a new field of the type string called ValidMonth.

Add another field of the type whole number (integer) called Day and give it the value substring(TodaysDate, 9, 2), now we know which day it is.

We should now give the submit button a rule.

Highlight the button, click on the button Manage rules in the ribbon.

The action we would like this rule to do for us is to set the value of ValidMonth to the name of the month for which this report should have. It could be the current month but it could also be the upcoming month if it is created between the 16th and 31st.

Create a new rule with the condition to be fired only if ValidMonth is equal to Empty and Day is less than or equal to 15. The action should be to set ValidMonth to the name of the current month. The rule should look like this:

But what if  we would create a new form between the 16th and 31st?
We need to create one more field to hold the name of the next month.

Give the field the name NextMonth with the value MonthNr +1

Ok, so now we have the number of the upcoming month, let’s use it to set the name of the next month.

Create one more rule for the save button with the condition to be fired only if ValidMonth is equal to Empty and Day is less than or equal to 31 and greater than 15. The action should be to set ValidMonth to the name of the next month. The rule should look like this:

There you go!

Now the form’s month is set only once and depending on if it should be valid for this month or the next, it will get the correct one. If you add these rules to the Form load it will be set when you open the form.

Editable until a certain date

Let’s add a rule for the submit button. Make it a formatting rule with the condition to only fire when Day is greater than 15 and mark the choice to Hide this control. That way the button will be hidden when the date is greater than 15th, and they will not be able to save any changes.

What if we want to create a new report between the 16th and 31st?
Ok, so we also need to check if ValidMonth is equal to MonthName, in that case the submit button should not be seen.

So, add another condition to that same rule that says:

and ValidMonth equals MonthName (be sure to use “and”)

Ok, there you go!

That was pretty easy 🙂



Name of month in expense report

Hi everyone,

Right now I am composing a form in InfoPath for an expense report. I thought that I would share a couple of things with you guys.

I will start of with this post and will probably follow up with one or two more.

In this post I will show you how I accomplished this:

  • Putting in the name of the month into the form

Ok, first of all you need to create a new data connection to get information from a XML-file.

Copy this code, put it in a Notepad and save it in UTF-8 format as Month.xml:

<?xml version="1.0" encoding="UTF-8"?>
<month id="1" name="Januari"/>
<month id="2" name="Februari"/>
<month id="3" name="Mars"/>
<month id="4" name="April"/>
<month id="5" name="Maj"/>
<month id="6" name="Juni"/>
<month id="7" name="Juli"/>
<month id="8" name="Augusti"/>
<month id="9" name="September"/>
<month id="10" name="Oktober"/>
<month id="11" name="November"/>
<month id="12" name="December"/>

Now create a data connection and choose to get data from another source such as a XML-file. Browse to the file Month.xml and choose to get data whenever the form is opened.

In the Main data source create a new field of the type string called TodaysDate.
Give this field the default value of Today() which will give you todays date.

Create another field of the type string called MonthNrText.
Give this field the default value of substring(TodaysDate, 6, 2) (that is when the date format is like 2012-01-06)

Now let’s create a new field and convert MonthNrText to an integer to take away the leading zeros.

Call this new field MonthNr and give it the value of number(MonthNrText)

Now we have the number of the current month, let’s make one more filed to get the name of this month.

Let’s create a field of the type string and name it MonthName. With this field we will compare the id in the secondary data source against our field MonthNr.
Give this filed the default value of @name[@id = MonthNr], this is how it is done.

Open up the properties of MonthName and click on the function-button to the right of the value field.

Click on the left button insert Field or Group... Choose the secondary data source Month and the field name. Then choose to add a filter to that data by clicking the button Filter data. A new dialog opens up where we choose to Add a new filter.

In the first drop down choose select a field or group and point to id in the secondary data source. In the second drop down choose is equals to and in the final drop down choose select a field or group and point to MonthNr. Here you have all the dialogs:

Ok, so there it is! Now we have the name of the current month.

In the next post I will show you how I made the form keep the name of the valid month, even if it is opened up later and how I made the form editable only until a certain date.



Get a link in a CQWP to edit an item

Hi everyone!

I hope this could be of some use for you 🙂

I want:

An audiense filtered list of links where by clicking the link, I should end up being able to edit the item, not open the page it points to. After I have finished editing I should return to the page with links targeted to me (or any other page for that matter).

Ok this is what we have:

A links list called OrgLinks where we have activated Audience targeting settings. This list also has a custom column called Box that is of the type Managed metadata which is connected to a Term store called Linkboxes.
So each item is tagged with which box it should belong to and which part of the organization that should see it.

I have a page that consists of a number of CQWP that is querying this links list. Audience targeting is activated on these web parts and they are filtered on the values of the Term store Linkboxes.

On the same page, I have added a couple of buttons (targeted to editors) to make it easier to create new items in this list and navigate to a page where you could edit items already created. This is actually the list that this blog is all about 🙂

The thing is that even if you enable Audience targeting for a list, you can’t OOTB filter a lists view on audiences.

This is where the template I came up with for ItemStyles.xsl comes in. It could be that I am crossing the brook for water in my template but it gives me the result I want 🙂

It was actually this template from Marc’s blog that got me in the right direction.

What it does is that it concatenate the link to the edit form of the item, the Item-ID and the URL to the page the user should go to after he or she is finished.

<xsl:template name="LinkListEdit" match="Row[@Style='LinkListEdit']" mode="itemstyle">
     <xsl:variable name="SafeLinkUrl">
         <xsl:call-template name="OuterTemplate.GetSafeLink">
             <xsl:with-param name="UrlColumnName" select="@URL"/>
     <xsl:variable name="DisplayTitle">
         <xsl:call-template name="OuterTemplate.GetTitle">
             <xsl:with-param name="Title" select="@URL"/>
             <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
     <xsl:variable name="TheList">
     <xsl:text disable-output-escaping="yes"> /alltomoss/_layouts/listform.aspx?PageType=6&amp;ListId={675357B2-D33C-4626-A61B-0FC978C0C09C}&amp;ID=</xsl:text>
     <xsl:variable name="Source">
     <xsl:text disable-output-escaping="yes">&amp;Source=/alltomoss/sidor/aoolankar.aspx</xsl:text>
          <xsl:variable name="TheLink">
          <xsl:value-of select="concat($TheList, @ID, $Source)" />
     <div id="linkitem">
         <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
         <a href="{$TheLink}" title="Redigera länken">
         <xsl:value-of select="substring-after($DisplayTitle,',')"/>

Before we actually could use this template and use it it in our CQWP we need to export the webpart and add a couple of things to it. Change CommonViewFields to look like this:

 <property name="CommonViewFields" type="string">URL,Text; </property> 

Then as “usual” import it again and add it to the page.



Working with the Visio Web Part

Hi everyone!

Ok, so a client had these requests:

1. We want to be able to navigate to different processes in an easy manner

2. We want to be able to bring up information about a process step

2b.Without loosing focus from the process we are currently at

3. Reuse instructions that we already have about the steps in our processes

This is what we will be working with:

  • A Visio file for the master process file that will be used to navigate to the different processes.
  • A Visio file for the process Customer Complaints, this process will contain two steps.
  • A PDF-file that will contain information about each step.
  • Two pages that will show the Visio-files.

First I would like to add that I am no expert in Visio so there might be better or different ways to attack this 🙂

As a matter of fact, I wonder if there is something that I am an expert in…

But anyway, this is how I did.

First of all I have these settings for Adobe Reader.

  • Set Adobe Reader to open PDF-files in the browser
  • Uncheck to open in Read mode as default

To accommodate request 1 (navigate to different processes)

A main process is created in Visio with links to the pages that holds a Visio web part for each process like Sales and Customer complaints and so on.

Main process

The link for the Customer complaints object looks like this:


This Visio-file is uploaded to http://server/site/processdiagrams as MainProcess.vdw

On the start page for http://server/site/start.apsx a Visio web part will be showing this Main process.

I also added a Go back button above this web part so that they in an easy manner could go back to the page that holds the Main process.

To accomodate request 3 (reusing information that we have)

First I made sure that the information about each process step started on a new page in the document. Then I saved the Word-file as a PDF letting Word create bookmarks in the PDF-file from the headings in the document while it was beeing published. That way we get a table of contents in the left navigation of the PDF.

(If you don’t get one, make sure that you have unchecked the default value to open PDF in Read mode.)

This PDF-file is uploaded to http://server/site/documents as CCsteps.pdf

To accomodate request 2 (bring up information on each step)

The Customer complaints visio-file (that is saved as a .vdw-file) holds two different steps ACC CC and Qualify CC.

Customer complaints

The link for ACC CC is configured like this:

URL: http://server/site/documents/ccsteps.pdf

The sub adress is “Page=2” (because the instructions for the ACC CC step starts at page 2)

Description is set to ACC CC and I don’t use a relative path.

This Visio-file is uploaded to http://server/site/processdiagrams as CustomerC.vdw

To accomodate request 2b (navigate without loosing focus)

Ok, so this is something that I don’t like with the new vdw-type of file, you can not set a link for an object to open in a new window.

So to get around this I first got some help on MSDN forum here >> with some javaScript.

On the Visio web part you want to have this script active for edit the web part like this:

I did not get this to work OOTB, so I got some help from some collegues of mine, thanks guys 🙂

This code you could simply copy and paste and put in a CEWP or FormWP on the page where you have your Visio web part, to try it out.

It ended up with a JavaScript looking like this:

<script type="text/javascript">

// Declare the global variables for the script, for the Visio Web Access Web Part, the active page in the Web Part,
// and the shapes on the active page.
var vwaControl;
var vwaPage;
var vwaShapes;
var newURL;

// Add a handler to the AJAX Sys.Application.load event.

function onApplicationLoad()
    // Capture a reference to the current instance of the Visio Web Access Web Part.
    // Add a handler to the 'diagramcomplete' event.
    vwaControl= new Vwa.VwaControl(getVWAWebPartID());
    vwaControl.addHandler("diagramcomplete", onDiagramComplete);

function getVWAWebPartID()
// Search all of the</pre>
<div>tags on the page to find the div tag with the ID of the VWA Web Part.</div>
  var divArray = document.getElementsByTagName("div");
  var webPartElementID;
  for (var i = 0; i < divArray.length; i++) {
    var node = divArray[i];
    if (node.className == "VisioWebAccess")
      webPartElementID =;
  return webPartElementID;

function onDiagramComplete()
    // Set the vwaPage and vwaShapes variables to the active page and the shapes collection on that page, respectively.
    vwaPage = vwaControl.getActivePage();
    vwaShapes = vwaPage.getShapes();

    // Remove the handler from the shape selection changed event and then add it back to the event.
    vwaControl.removeHandler("shapeselectionchanged", onShapeSelectionChanged);
    vwaControl.addHandler("shapeselectionchanged", onShapeSelectionChanged);


function setNewPage(pageId) {
  // Set the active page in the drawing to the page ID passed in as argument.
  var indexOfAmp = pageId.indexOf("&");
  var page = pageId.slice(6, indexOfAmp);
onShapeSelectionChanged = function (source, args)
    // Get the array of hyperlinks from the selected shape.
    var vwaShape = vwaShapes.getItemById(args);
    var newURLArray = vwaShape.getHyperlinks();

    // Check to see whether the shape has any hyperlinks.
    if (newURLArray.length> 0)
      newURL = newURLArray[0].value;

      // Check to see if the hyperlink goes to another page in the drawing.
      if (newURL.indexOf('vdw') < 0)
        // Open the hyperlink in a new window.
           var newWindow =, "", 'width=800,height=650')
         //Set the active page to the new page.

Now when you click on a process step, the actual page in the PDF-file should be brought up in a separate window and give you the instructions about that step. You should also have a table of contents in the left pane in AcrobatReader so that you could easily navigate between different instructions.

Well thats about it guys, I hope this will help you or give you some ideas.



Version and ID in printed document

As you probably already know it’s possible to add Quick Parts in Word to add metadata from custom columns in your header/footer.
But getting Version or ID in the header/footer is a whole other bargain.

It’s really important to get this information inside the document, so that it’s possible to see on a printed copy, what version it is compared to the latest version in SharePoint.

So how should we accomplish this?

• Make sure you have a document with a header section.
• Create a Content type and add this document as the template.
• Navigate to a document library and activate Versioning and the possibility to handle Content types.
• Add your Content type to the library.
• Navigate to the settings for the library and then the settings for the Content type. Click on “Information management policy settings”.
• Check “Enable Labels” and add: {Version}nDok.ID: {ID} in “Label format”. Make changes regarding the style as it fits you.
• In advanced settings for the Content type, choose to edit the template.
• Put the cursor where you want to have the Version and ID added.
• Click on Insert, Quick Parts, Document property and Label.
• Save, click Ok and try it out.

The first time you open up the document it looks a little bit strange because there is no version yet, but don’t worry, save and open the document again and behold the version.


Custom Meeting workspace site template

In a project I recently worked in I found out the hard way that it wasn’t possible to save a Meeting workspace (MW) as a custom template to recreate sites from. I also found out through Bing that I wasn’t alone in my discovery 🙂

The other day I was discussing this with a colleague and by reproducing it I wanted to show him that the left navigation on the site between the different meetings would crack.

So I saved a MW as a new template and from that template I created a new MW from a calendar event. Then I created another calendar event and linked to the same MW. Navigating to the MW I could now see the two dates in the left nav. And do you know what? It worked!

I could actually navigate between the two dates! This has never worked before!

So why does it suddenly work? SP1 for SharePoint 2010 🙂

My colleague who did not have SP1 installed, doing the same thing in his dev environment, got the old behavior, left navigation cracked. After installing SP1 he didn’t have the problem any longer.

Isn’t that great? When SP1 was released I actually went through the Excel file with all the fixes and couldn’t find anything about this. I wish it could have been mentioned, it would have saved me and the client a lot of time.

Another thing to be aware of when you have meeting workspaces in a site collection and you for that site collection, wants to push out a custom master page on all sub sites. If you do that, the MWs will also be getting your custom master page. As you already might know, MWs have their own master page.

The result you will get by doing this is that (again) the left navigation will crack. You will get a JavaScript error telling you that a property bag is missing.

To fix this you will have to add this into your custom master page.

At the top add this Tagprefix:

<%@ Register Tagprefix=”Meetings” Namespace=”Microsoft.SharePoint.Meetings” Assembly=”Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
Below the FORM-tag below the BODY-tag add:

<Meetings:PropertyBag runat=”server”/>

There is one more thing to add to this. In a MW there are two more options in the Site Actions menu.

“Add Pages” and “Manage Pages”. These two options will also be lost when you apply another master page than the default for a MW. I don’t have a solution for how to handle that as for now. But some how I think it’s needed to make the Site Actions menu dynamic and show these options only if the site is created from a MW template.