Monthly Archives: February 2011

Changing Site Column Groups in SharePoint Designer 2010

I created a slew of site columns using SharePoint Designer 2010 this morning and realized that I had given them all the wrong group.  It was embarrassingly difficult to figure out.  I didn’t know where to click…

image

I kept wanting to double click the row itself or click the Column Settings button in the ribbon.

As it turns out, the correct answer (or at least one correct answer) is to single click on the group itself.  Wait a moment and then it will allow you to enter a value, as shown:

image

Pretty easy once you know what to do, but it eluded me for a bit.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Manually Edit SPD XOML File to Clean Up Variables

In this post here (“Getting Answers Back from the Start Approval Process Activity”), I mentioned that you can accidentally add a whole slew of workflow variables to your SharePoint Designer workflow.  Things can quickly become cluttered and hard to read.  Specifically, if you add the “Start Approval Process Activity” action to your workflow, delete it and add it again, you end up with all of that activity’s workflow variables twice. 

It’s a real pain to go through and delete all of those manually, so I though I would try to remove them directly from the XOML file.  This proved to be easy enough to do. 

First, you need to locate the actual XOML file.  I wrote about that topic here: http://www.mstechblogs.com/paul/how-to-find-and-edit-spd-2010-workflow-xoml-files.  Once found, open up the XOML file and locate a variable you want to remove.  In this case, I added the "Start Approval Process” activity to my workflow twice.  I want to remove a workflow variable named “isItemApproved” since it’s no longer used and there is a duplicate variable named “isItemApproved1”. 

Simply do a text search for the variable.  My screen looks like this:

image 

If you search around in the XOML file, you’ll see that “IsItemApproved1” is used in many different places while the original "IsItemApproved” is simply defined once and never used.

Delete it and then save the file.

The only tricky part is that I had to actually close out SPD altogether and re-open it before SPD acknowledged that the field deleted.

Of course, deleting fields isn’t the only thing you can do with the XOML and I may blog about other topics like this in future.

You want to be very careful about what you do here and take backups of your work.  You can make a seemingly minor / subtle change here that trashes the workflow as far as SPD is concerned and you could lose hours of effort while you rebuild it.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

How to Find and Edit SPD 2010 Workflow XOML Files

I was researching an easy way to remove a bunch of workflow variables without having to spend my afternoon in a full blown SPD click torture session.  My thought was to edit the XOML directly, which is the XML file underlying SPD’s declarative workflows.  This is how I found it.

First, go to the All Files option under Site Objects in Navigation.  You need appropriate permissions to see this, so if it’s missing for you, appeal to the right admin person to grant you the priv.  This is what it looks like:

image

 

All Files shows a list of … all the files:

image

Select the Workflows folder and you see a list of folders for each workflow:

image

Click into the correct folder and  you see a listing of all the interesting goodies that make up an SPD declarative workflow.  Right click on the .xoml file and select “Open With –> SharePoint Designer (Open as XML)” to edit the XOML directly:

image

You may want to do a manual backup before you fiddle with things.  A regular copy/paste of the file directly in SPD is probably good enough, or you can copy paste the entire XML text and save it onto your desktop or whatever is your wont in these cases.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Getting Answers Back from the Start Approval Process Activity

I’ve been playing around with SharePoint Designer workflow’s fancy new “Start Approval Process” activity and was quickly stymied because I couldn’t right away answer the question, “was it approved or not?”. 

The short answer is that it’s quite easy to get the answer.  When you add this activity to your main workflow, SPD adds a bazillion variables to the Workflow Variables and Parameters data source, as you can see here:

SNAGHTML2350fe72

You’ll also note that if you add more than one of these, SPD appends a “1” and so forth to all of the variables. 

I found that when I deleted the first “Start Approval Process” activity, the first set of associated workflow variables remained (sadly).  So, be careful how you use this because otherwise, you’ll end up with  a very cluttered list of workflow variables.

I give Microsoft credit for following the “is” naming convention for a Boolean variable.  This convention makes it pretty clear what kind of data is supposed to be there.

In researching, I found this helpful article: http://office.microsoft.com/en-us/sharepoint-designer-help/workflow-actions-in-sharepoint-designer-2010-a-quick-reference-guide-HA010376961.aspx.  It doesn’t really address this specific issue, but has some good information on the topic so I’d go there if you want to learn more about this specific activity and its siblings.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

SharePoint Designer 2010 MOD function

I am working out some log where employees can request vacation, sick time, etc. One validation rule requires that you must always request time off in 4 hour intervals.  This is easy enough to do – use a modulo function.  Modulo function tells you the remainder in division.  If there is no remainder, modulo is zero, otherwise, it’s whatever is left.  For instance, 8 mod 4 = 0 (8 / 4 = 2 with no fraction).  On the other hand, 8 mod 5 is 3.

I needed to do this once with SPD 2007 once upon a time and I actually ended up using an InfoPath form to solve, so it was handled on the front end at the time.  In the current case, there may be an InfoPath form in the picture, but that’s not clear yet.  So, I was working out a technique to ensure that time requests are always in 4 hour increments.  I was going to do the math, save it in a string and then do some substring stuff. 

I pull up SPD 2010 and to my surprise (and a little embarrassment) there is a modulo function already:

image

I am once again pleasantly surprised that something I needed is already there out of the box.  It does seem like a weird function for Microsoft to include in the mix.  It has a sort of “this is easy, so let’s throw it in” feel to it.  I sympathize with that, as I do it myself all the time.  This CodePlex project has a bunch of little functions that result from the ItsEasy principle.  At the same time, Microsoft continues to support evidence the “95% of the way” effect with the product.  They implement the Mod function, but not the round function, for instance.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

CodePlex Project – SP2010 Explorer

As part of an on-going effort to learn the technical low level details of SharePoint 2010, I’ve created a “SharePoint Explorer” kind of tool.  The idea isn’t new.  I used this project more than once: http://sharepointexplorer.codeplex.com/.  My idea is to create a SharePoint version that uses connected web parts to show all the low-level detail that the object model can provide. 

This blog post serves as both an announcement of the project as well as a call for volunteers.  If you’re interested in working on this project, let me know via email (galvin.paul@gmail.com) and we’ll work it out.

Here is the project: http://sp2010explorer.codeplex.com/

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

SharePoint Designer 2007 Workflow Extensions CodePlex Project

I am putting together my second CodePlex project (details to be announced on Wednesday this week, plus or minus) and I had a look at my first project, “SharePoint Designer Workflow Extensions”.  I was shocked and embarrassed to see that that it’s been downloaded over 4,800 times:

image

I basically forgot about this project in the last 12 months.  I’m embarrassed because I have essentially abandoned it.

I’m going to have another look and remind myself of what it’s all about. 

If anyone is interested in working on this, let me know and we’ll see about collaborating on it.  4,800 downloads isn’t a giant amount, but it’s more than I ever realized and it’s probably worth some effort picking it up and carrying it forward.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Export-SPWeb Tells Me “InvalidData” But the Data is Valid

I’m in the process of writing an article for the good people at www.sharepointbriefing.com and it involves deploying an list from a development farm to a production farm.  I’m still accustomed to using stsadm and need to break that habit, so I fired up the SharePoint 2010 Management Shell and played around using Export-SPWeb to backup my list.  What a strangely difficult thing that proved to be!

I kept getting this error:

image

That error, “InvalidData: (Microsoft.Share…CmdletExportweb"”) was killing me.  I’m embarrassed at how long I struggled with this.

I had previously run into a wall with PowerShell and used stsadm to get around it.  I tried it again this time and I got good results.

I spent a lot of time fiddling around with the –Identity option and then finally with –ItemURL.  It turns out that the ItemURL option requires a full path of the list/library you  want to export without the http://server bit.  So, despite the fact that the Identity argument is pointing to a subsite, the ItemURL is not relative to the Identify but relative to the site collection.

It would have been nice for the cmdlet to tell me what was minimally valid (the Identity in this case) and what was invalid (ItemUrl).  These little touches help people embrace the product.  Not a big ding against SharePoint, but a little one at least 🙂

Hopefully this post will save someone a bit of grief in future.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin

Working With TreeNodeBinding in the ASP.NET Treeview Control

I’ve been working on what I hope will be a soon-released CodePlex project that provides a nice integrated bit of web parts talking to each other via provider/consumer connections for the purpose of exploring a SharePoint site under the covers.  (This has certainly been done before, but this is a learning project as much as anything else).  This is meant to be a replacement for the windows explorer view of SharePoint 2010 document libraries.

The code has the usual recursive call down the SPWeb’s and SPLists from a given starting point.  The object that does all that traversing builds up an XML string that looks something like this:

<sitecollection url=’http://demo2010a:9090′>
 
<web
     title=’Hello World Sandbox’ 
     Template=’A site for teams to quickly organize, author, and share information, BLAH BLAH BLAH’>

     <list
        title=’BCC_Health_Services_FAQs’
        Template=’CustomList’
       
listid=’http://demo2010a:9090/helloworldsandbox[delim]1e02b001-3cb2-4f17-b63d-7809e86b4174′>
    
</list>

     <list
        title=’BCC_Notifications’ 
        Template=’CustomList’ 
        listid=’
http://demo2010a:9090/helloworldsandbox[delim]5a5a13d1-877c-41c0-9063-b9612be80d5e’>
     </list>

  </web>

</sitecollection>

I expect to clean up that XML before all is said and done.

I want to ultimately get that information up and into a Treeview control.  Not exactly earth shattering stuff.

The challenge I took on here was to connect the tree view to an XML Data Source control instead of manually building up my treenodes as I traverse the tree.  I did this partly because I’m deliberately making things harder on myself (this is a learning project after all) and partly because I have this vague notion that building up tree nodes as I traverse the tree isn’t a good idea for the long term.

The problem with this approach is that the Treeview control doesn’t know about the good attributes on the interesting nodes like “list” or “web” so it shows this output by default:

 

image

That’s not useful.  This is where the TreeNodeBinding class helps.  I can use this to tell the Treeview control how it should interpret the XML.  Here’s an example:

tnb = new TreeNodeBinding();
tnb.DataMember = "list"; // This is the label in the xml for a site.
tnb.TargetField = "listid";
tnb.ValueField = "title";
tnb.ToolTipField = "Template";

This binding tells the treeview that when it finds a <list> node in the XML, apply the bindings for TargetField, ValueField and ToolTipField.  In may app, these map as follows:

  • TargetField: When someone clicks on a node value, this is what you’ll get for SelectedNode.Value.  This is not to be confused with…
  • ValueField: This is what you want the Treeview to display to the user.
  • ToolTipField: The value from the XML that you want as a Tooltip.

Add that TreeNodebinding to the tree view’s DataBindings and you get output like this:

 

image

I’ll have more on all this as I continue on the project and eventually put this up on Codeplex.

</end>

Subscribe to my blog.

Follow me on Twitter at http://www.twitter.com/pagalvin