Archive for February, 2008

Are you new to SharePoint / K2 [blackpearl]?

If you are, Microsoft gold partners CORE are offering a free seminar so you can learn about all the advantages of SharePoint and K2 [blackpearl].

Details can be found here: Core presents Microsoft Office SharePoint and K2 BlackPearl Workflow – FREE half day seminar with live demonstrations

The event will be held on the 24th April 2008 at 09:30 - 13:00 GMT in London at Microsoft’s Putney/Westminster office.

Nearest tube/station is Victoria.

I hope to attend so I can meet some of you and help spread the knowledge

SpittingCAML



Potential Issues when deploying a SmartObject that integrates with the SharePoint ServiceObject

Why am I writing this particular article… well I had this problem and wasted the best part of a day on trying to solve it…. and it wasn’t exactly straight forward.

This issue only occurs when the following are true:

  1. You have created a SmartObject that interacts with the SharePoint ServiceObject, e.g. calls the service object to get a list of users that belong to a SharePoint group
  2. You build your deployment package on your development server and install on your destination server via the console i.e. using msbuild rather than using Visual Studio to do the deployment
  3. You have SharePoint (MOSS) installed on your development server, and on your destination server
  4. You have K2 BlackPearl server installed on your development server and on your destination server

How you know you’ve got this issue:

  1. You will receive errors when running msbuild, with the error messages saying that it cannot find your SharePoint URL even though you know it exists on the destination server
  2. Any SmartObjects that interact with SharePoint will fail to deploy

Why is there an issue you ask… well it’s relatively simple. When you interact with the SharePoint service object the K2 Service Broker looks for the GUID representing your SharePoint instance… when you deploy to another server where another copy of SharePoint is installed, this GUID will be different, so the deploy will fail.

To explain in more detail, follow steps below

servicebroker1
Figure 1: The Service Broker Management application

On your development server: Navigate to the install folder for K2 [blackpearl] and find the BrokerManagement.exe (Shown in Figure 1). Execute the BrokerManagement application.

servicebroker3
Figure 2: the K2 [blackpearl] broker management application front end

Click on ‘Configure Services’ as shown in Figure 2.

servicebroker2
Figure 3: Finding your SharePoint instance GUID

You will now need to look for your SharePoint instance GUID. I’ve shown an example of this in Figure 3.

If you repeat this process on the destination server you’ll see that the SharePoint instances will have differing GUID values.

The dirty fix:

Do a search and replace (in the files created by the deployment package) on the GUID from the development server with the one on the destination server to ensure correct deployment using msbuild

I believe that following this issue the K2 Labs are currently working on a fix for this issue.

SpittingCAML



How to debug (in real-time) a K2 [blackpearl] workflow using Visual Studio breakpoints

Now why would you ever need to go to the trouble of debugging the code that a wizard produced or to validate some logic in this long winded fashion I hear you asking…..

Well, when you’ve pulled your hair out for too long and the K2 support ticket guys are asking difficult questions this is definitely the way to look more deeply into the goings on in your K2 [blackpearl] workflow.

debugK2_2
Figure 1: Attach to process option 

The first thing you need to do is to fire up Visual Studio (K2 Designer) and go to a piece of code that you want to debug. I’ve selected a code event that I’ve created myself, but there’s no reason why you can’t stick a breakpoint inside a wizard. This is shown in Figure 1, as is the attach to process option that you’ll need to use to kick off the debugger.

debugK2_1
Figure 2: Attaching to the K2HostServer.exe process

Once you’ve clicked the attach to process option you’ll need to find the K2HostServer.exe process (as shown in Figure 2) and select it.

Don’t click the Attach button yet.

debugK2_6
Figure 3: Ensuring ‘Managed Code’ is selected

Make sure the ‘Attach to’ option only says Managed Code as shown in Figure 3. You can change this using the ‘Select’ option on the attach to process dialog.

debugK2_7
Figure 4: Security Warning message

You might see the security warning shown in Figure 4, or an error message if you don’t have rights to attach to the K2HostServer.exe process. You probably need to be at least an administrator on the server. Ignore the security warning and click ‘attach’ to carry on.

debugK2_4_1
Figure 5: Visual Studio Breakpoint warning after attachment

Now, you’ll now see Visual Studio frantically loading assemblies in the background - this is normal. You’ll also notice that your breakpoint now displays an error similar to that shown in Figure 5. This is okay, it’s just Visual Studio warning us that our code is not yet in context - you need to initiate your workflow and get to the point in the workflow where your breakpoint exists before it will be a valid breakpoint.

debugK2_5
Figure 6: The breakpoint is now active! 

Figure 6 shows an active breakpoint as the workflow has reached the part of the code!

You can now use the watch window to look at variables.

SpittingCAML



SharePoint User Group UK meeting: 27th Feb 2008

… well having never had the pleasure to actually make on of these, I’m on the lookout for a day that I’ll be able to attend.

For all you SharePoint developers and admins, see if the next meeting on the 27th February in London is good for you. I would recommend attending from the reviews alone.

27th February in London

and checkout other up coming meetings

SpittingCAML


By SpittingCAML in SharePoint, Training  .::. Read Comments (2)

Syndicating spreadsheets with MOSS 2007 utilising a list… and the SharePoint beagle

Something a few of our users frequently request is whether it would be possible for them to display their ‘business critical’ spreadsheet to the rest of the organisation.

While I harbour resentment for the use of a spreadsheet for business critical data, I am supposed to help them out occasionally.

I found a nice introduction to it on the SharePoint beagle, a collaborative project with a few Microsoft most valued professionals (MVPs) taking the helm… this will probably be huge in a few months, but it looks like it’s just getting going at the moment.

The introduction to syndicating spreadsheets: here
… and the main site: here

SpittingCAML


By SpittingCAML in SharePoint  .::. (Add your comment)

Free SharePoint Tools!

The nice guys at Black Blade Associates, Inc have provided some free tools and the source code for these tools is included!

  • Clear SharePoint List Items
  • SharePoint Document Section Manager
  • SharePoint List Item Workspaces
  • SharePoint Zip
  • Check them out!

    SpittingCAML


    By SpittingCAML in SharePoint  .::. (Add your comment)

    Modifying the contents of a SmartObject using the SmartObject event, and then loading the SmartObject into InfoPath

    This blog post is really a little tutorial that I’ve been working on to help people understand how to utilise SmartObjects as part of their InfoPath forms. I, like many, just think it’s more logical to store data in the SQL database (SmartBox) rather than to store it as XML (in the InfoPath form itself. This tutorial should help you get an idea of how to use SmartObjects to persist your data, while keeping the familiar InfoPath front end for your users.

    First you need to create your SmartObjects using the Visual Studio SmartObject project. This tutorial wont cover that as it’s covered in the K2 [blackpearl] 101 guides. Make sure that when you do create them that you give them a Load and Save method in order to follow what I’ve done here.

    tutorial1
    Figure 1: K2 [blackpearl] SmartObject Event wizard

    Figure 1 shows a SmartObject event wizard. I am using this wizard to set some values of the SmartObject. I will be calling the ‘Save’ method of my SmartObject ‘cmmiDocumentDetail’.

    tutorial2
    Figure 2: K2 [blackpearl] SmartObject Event wizard (2) 

    Figure 2 shows the values of my SmartObject that I will be populating outside of InfoPath. I’m populating ‘currentAuthor’ with the Activity Instance Destination User (how to get this particular value is explained on this blog too :-)) and current role with a string "Review" and the ‘documentAutoNumber’ with a value from a previous InfoPath form. Populating this field is a key requirement, as this is the index of my SmartObject. If you do this sort of thing you will need to populate this value to make sure you are updating the correct instance of your SmartObject.

    tutorial3
    Figure 3: K2 [blackpearl] InfoPath Integration wizard

    If you haven’t already done so, integrate your SmartObjects with your InfoPath form using the edit mode provided by the InfoPath integration mode. You may encounter issues if you’ve added your own datasources before integrating your SmartObjects. See K2 Underground. After you’ve integrated each of the SmartObject methods that you want to use (Yes, you need to integrate each method separately!) you can carry on with this tutorial.

    Figure 3 shows the ‘design’ mode that you will need to enter in order to make any changes to an InfoPath form that is already integrated with your workflow. You really shouldn’t modify the InfoPath form outside of Visual Studio once you’ve integrated… it’s just not worth the risk ;-).

    tutorial4
    Figure 4: InfoPath form options selection

    Figure 4 shows the form options mode that we’ll need to go into in order to invoke the SmartObject methods that we will require.

    tutorial5
    Figure 5: InfoPath open and save rules selection

    Figure 5 shows the open and save rules that we need to get to to invoke the SmartObject methods on form load event.

    tutorial6
    Figure 6: InfoPath open and save rules

    You’ll now need to add an action to invoke the load method of your SmartObject. If you require to load multiple SmartObjects you’ll need to add actions for each one separately. Figure 6 shows two Queries, one a ‘Get List’ and one a Load method on two separate SmartObjects. If you invoke a SmartObject method that has an input parameter, you’ll need to add another action that sets a field value on the relevant data source (See Figure 7 below)

    tutorial7
    Figure 7: InfoPath data source window showing the load method and it’s required input 

    Figure 7 shows a required input parameter to the load method. This is the field that you will need to set before you query the SmartObject. If you look at Figure 6, you’ll see that I set ‘docAutoNumber’ to be equal to a value before I invoke the Query. This is important as the SmartObject method will error if no input parameter is provided.

    Now that you know that when the form opens you will be automatically executing the SmartObject methods you can set about assigning your SmartObjects to controls on your InfoPath form.

    tutorial8
    Figure 8: InfoPath data source window showing the return values for the load method 

    Figure 8 shows the set of values that can be bound to existing InfoPath controls or dragged and dropped onto your InfoPath form to automatically create controls. Once controls are bound or created you need to ensure you call the ‘Save’ method on your SmartObjects.

    tutorial9
    Figure 9: InfoPath submit rule options

    Figure 9 shows a rule that is executed on form submit that calls the Save method on my SmartObjects. ‘Set Workflow Task Action 1′ and ‘Submit Workflow’ are automatically added by K2 [blackpearl] when you have performed a K2 [blackpearl] InfoPath integration wizard.

    I know this is sparse in places… but I hope it helps some of you.

    SpittingCAML


    By SpittingCAML in InfoPath, K2 [blackpearl]  .::. (Add your comment)

    Setting an InfoPath field value outside of InfoPath in a K2 [blackpearl] workflow

    The following code shows how to set an XML field on an InfoPath form in a server code event. The example uses ’smartObjectID’ as the variable that I am using as the input to the InfoPath field. ‘form2Name’ is the name of the InfoPath form as it appears in the K2 Object Browser in Visual Studio. ‘hiddenSmartObjectID’ is the name of the text box control that I’ve placed on my InfoPath form. Once the code has completed execution, the form form will load with the value already set allowing the utilisation of it at a later time in the workflow.

    This is useful when you are providing more than one form to the user via Infopath client events, and the data needs to be linked in some way.

    smartObjectID =
        <whatever value you need from either K2 or previous forms> 
    
    // we need to get the xml from the K2 state datastring k2xmlString =
        K2.ProcessInstance.XmlFields["form2Name"]    .Value.ToString();
    
    // get stuff from form2
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(k2xmlString);
    
    // create a namespace manager for InfoPath
    XmlNamespaceManager nsMgr =
        new XmlNamespaceManager(xmlDoc.NameTable);
    nsMgr.AddNamespace("my",
        xmlDoc.DocumentElement.GetNamespaceOfPrefix("my"));
    
    // set the value of a hidden field to be equal to the id 
    // required for retrieving the correct smartobject
    // NOTE: I've got a hidden text box on my infopath form
    // called 'hiddenSmartObjectID' that I'll be using later
    xmlDoc.SelectSingleNode
        ("//my:Form2Fields/my:hiddenSmartObjectID", nsMgr).Value =
              smartObjectID;
    
    //Now set the value back into the XML Field
    K2.ProcessInstance.XmlFields["form2Name"].Value =
         xmlDoc.OuterXml;

    Let me know how you get on with this. :-D

    SpittingCAML


    By SpittingCAML in InfoPath, K2 [blackpearl]  .::. (Add your comment)

    Utilising the ‘Destination User’ as an input to an event in K2 [blackpearl]

    The destination user can be a fairly common artifact that you need to retrieve during a workflow, however, even though you may have specified a destination user in your form, ASPX or SharePoint integration event you may find that the contents of the user in the activity instance is blank because of the way you configured the destination rule.

    destRule0
    Figure 1: The activity strip

    Open the activity strip (something I didn’t know existed till a K2 guru pointed it out to me) and select Destination Rules

    destRule1
    Figure 2: Advanced Destination rule configuration (1)

    You’ll need to scroll back one item on the wizard to ensure the wizard runs in advanced mode before you’ll see the screens shown in Figure 2 and 3.

    By default K2 [blackpearl] will be in ‘plan just once’ mode. This wont create you a destination user, it will create an activity that can be filled in by any user, just once. Select plan per destination, and you’ll guarantee that one or more specific users get the activity only!

    destRule2
    Figure 3: Advanced Destination rule configuration (2)

    Clicking next on the wizard will bring you the screen shown in Figure 3, this allows you to specify the number of ’slots’ that this activity will have.

    End the wizard, and you should find that you can now use the activity destination instance as an input to another event on your workflow. I believe this may only work if you specify one slot and one user, but will try it out to see what exactly happens when I specify multiple slots and multiple users in the destination rule wizard.

    destRule3
    Figure 4: Location of the destination user inside the Activity Destination Instance

    Figure 4 shows the location of the ‘Destination User’. This can be used to assign a task if integrating with SharePoint task workflow, or for filling in a field on an infopath form to create and audit of who filled in the form.

    Enjoy

    SpittingCAML


    By SpittingCAML in K2 [blackpearl], SharePoint  .::. Read Comments (3)


    You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.