The K2 Pirate

February 2, 2012

Renew K2 Licence Key

Filed under: General — hoshy @ 1:59 pm


Credits to Markus Alt of K2 Norther Europe for this guide.
 
In case you have to renew your K2 license key, there’s a just a few steps you need to do here.
 
First go to your K2 Server and load the K2 blackpearl Setup Manager from the Start menu.
 
 
Then you select Configure K2 blackpearl
 
 
The System Key is a hash value created onto the system, you should not modify that.
You just have to copy your new License Key to its field. This windows also allows you to request a new key, in case you do not already have one.
 
 
There’s nothing else to do then finish the wizard and restart the K2 blackpearl Server.
So, open up the Services console.
 
 
Lookup the K2 blackpearl Server and restart it.
 
You’re done.
 
 

January 27, 2012

XML Fields added by the K2 SharePoint wizards (SPWFI/SP Events/Item Reference wizards)

Filed under: General — hoshy @ 3:36 pm
Credits to Neil Maartens, K2 Learning
Hello, it’s your friendly neighborhood training-content guy again with some bedtime reading
One of the benefits of this gig is that I get to investigate those things that have always bugged me in the field, like “what are those XML fields that are added to a process by the SharePoint wizards, and what’s inside them?”
The following write-up is extracted from a new learning module that will be available shortly (300.HLP K2 and Microsoft SharePoint Content Management). I thought it would be good to share what I’ve discovered since you may need to use this info in real projects sometime.
So without further ado, a breakdown of the various XML datafields added by the SharePoint Workflow process, SharePoint Events process and Item Reference event wizards:
Fields Added by the SharePoint Events Process Wizard
When you use the SharePoint Workflow Integration wizard to expose a K2 workflow as a SharePoint workflow, K2 will create 4 XML datafields in the process automatically.

SPComments (hidden)

This (hidden) datafield is very useful to know about, since the comments entered by users during Client Events are saved into the XML field. If you wanted to include comments from the manager as to why the request was rejected, for example, you can find the manager’s comments in this XML structure. The table below describes the values saved in this XML datafield.

Showing hidden fields and the SPComments datafield

Field Value Stored Sample Value
Comments A repeating node containing all the comments entered by various users during the workflow Client Events n/a
EventName The name of the Client Event for the user task Manager Approval
Comment A repeating node, since a task may have had more than one user’s input n/a
UserName The user name of the user that completed the task DENALLIXadministrator
DisplayName Display Name of the user that completed the task DENALLIXadministrator
DateTime The date that the task was completed 1/26/2012 2:40 PM
Body The comment body entered by the approver Not _x0020_enough _x0020_leave _x0020_days

Note that the special characters like space are encoded.
Action The action selected by the user when completing the item Rejected

SharePoint_Item

The SharePoint_Item XML datafield stores all the metadata values for the item based on the item content type. The structure of this XML datafield will vary between different lists, so we won’t list the fields in the structure here. For reference, the screenshot below just shows the type of data saved in the SharePoint_Item datafield:

Structure of the SharePoint_Item XML datafield

SPIntegrationData (hidden)

The SPIntegraiotn XML datafield is used by K2 to store the details relating to the K2/SharePoint Workflow integration.
The Screenshot below shows the structure of this field., and the table following describes the fields in this XML strcuture:

The SPIntegrationData XML Field Structure

Field Value Stored Sample Value
HistoryListId Internal SharePoint ID of the List used to save the Workflow History 38ac23da-22cf-4628-b56d-708a5c887f65
HistoryListURL The relative URL of the workflow history list

The URL is relative form the root site of the site collection
/K2Learning/Lists/Workflow History
HistoryListName The Display Name of the workflow history list Workflow History
ItemName The Name of the item submitted to workflow Test Item    
ItemTitle The Title of the item submitted to workflow Test Item
ItemId The SharePoint ID of the item submitted to worfklow 2
ItemUniqueId The internal SharePoint ID of the item submitted to workflow 28fe05a3-6563-4d9d-906d-bc59c4bbe70e
ItemURL The relative locaiotn of the item submitted to workflow.

The URL is relative to the URL of the Site where the list is defined.
Lists/SharePointWorkflowList/2_.000
ListTitle The title of the list where the item resides SharePointWorkflowList
ListId The internal SharePoint ID of the list where the item resides 675684a7-8090-461c-8076-e18c83ed83c7
ListURL The relative URL of the list where the item resides.

The URL is relative from the root site of the site collection
/K2Learning/Lists/SharePointWorkflowList
OriginatorName The name of the user that submitted the workflow DENALLIXadministrator
OriginatorLoginName The login name of the user that submitted the item to workflow DENALLIXadministrator
OriginatorId The internal SharePoint ID if the user that submitted the item to workflow 1
OriginatorEmail Email of the person who submitted the item to workflow administrator@denallix.com
SiteTitle The title of the root site of the site collection PortalRootSite
SiteId The internal SharePoint ID for the root site of the site collection 54707d5b-9e8d-410e-aec7-84ebca121dbb
SiteURL The URL of the root site of the site collection http://portal.denallix.com
TaskListTitle The title of the task lists where user tasks will be displayed Tasks
TaskListId The internal SharePoint ID of the task list where user tasks are displayed a0dbb13c-9ba3-4d59-a086-74c52a24efcd
TaskListURL The relative URL of the task list where user tasks are displayed.

The URL is relative to the URL of the root site on the site collection
/K2Learning/Lists/Tasks
WebId The internal SharePoint ID of the site where the list resides 4217499d-9fa3-4715-9c32-f02cb9086d05
WebURL The full URL of the site where the list resides http://portal.denallix.com/K2Learning
WorkflowId The unique SharePoint ID for the SharePoint workflow 5840d436-8b67-4808-ac2c-03e9921c1871
TemplateName The name of the SharePoint workflow K2LearningTestsSharePointWorkflowIntegrationProcess
InternalState A list of valid sates for the SharePoint workflow Locked, Running, NotStarted
AuthorUserLoginName Login name of the author of the item DENALLIXadministrator
InstantiationData A collection of instantiation data when the workflow was started (depends on the item being submitted)
CustomData Custom data (not used)

WFIProcessField

The WFIProcessField XML datafield added by the wizard is a standard Content Field/Item Reference Field. The screenshot below shows the structure of this XML field, and the table following describes the fields in this structure.

The structure of the WFIProcessField

Note: The sample values are based on a list item created in a list located at http://portal.denallix.com/K2Learning/Lists/SharePointEventsList
Field Value Stored Sample Value
Type The Content Type of the item ListItems
Item (repeating node) This is a repeating XML node. Multiple Items can be listed under this repeating node.
ID The index of the current item in the Item repeating node 1
SiteURL The URL of the site where the item list is located http://portal.denallix.com/K2Learning
ListURL The relative URL of the list where the item is located.

The URL is relative to the Site where the list exists.
Lists/SharePointEventsList
FolderURL The name of the folder where the item exists.

If no folder, the Item ID is used.
TestFolder

or
2_.000
Item The ID of the item that started the process 2
URL The full URL to the item.

Can be used as a hyperlink to open the Display Page of the item.
http://portal.denallix.com/K2Learning/Lists/SharePointEventsList/DispForm.aspx?ID=2
Source (Not relevant for the SharePoint workflow integration wizard)

List Item MetaData

When you run the SharePoint Events process wizard, you may elect to save the metadata of the list item that started the workflow into a Process-level XML datafield.

Selecting whether to save the metadata of the item that started the workflow

The structure of this data field will depend on the definition of the list or library where the item is created, so we cannot provide a definitive screenshot or explanation of the structure. However, the screenshot and table below describe an example of this XML datafield for a sample list.

A sample XML Datafield representing the Metadata of a List Item

Note: each field has two sub-properties: Title and Name. Title is the display name of the property in SharePoint, and Name is the internal system name for the property in SharePoint.
Field/Field Data Type Notes Sample Value
Choice Saves the Name of the item selected in the choice drop-down Option 1
DateTime
(e.g. Created, Modified or custom date field)
Timestamp for the SharePoint server where the item was created 2012-01-26T11:54:10
Lookup The ID and Value of the selected lookup item 2;#Finance
User

(e.g. Author or custom user field)
Stores values in domainusername for AD users DENALLIXadministrator
ID The SharePoint List Item ID 2
Title Stores the title Test Item
YesNo True or False value True
Fields Added by the SharePoint Events Process Wizard
When you use the SharePoint Events Process wizard to associate a K2 workflow with a SharePoint event, K2 will create two XML datafields in the process automatically. It is valuable to know about these datafields, since you may need to use these fields when interacting with the list item at a later stage of the workflow.

SPEventsField

The SPEventsField XML datafield added by the wizard is a standard Content Field/Item Reference Field. The screenshot below shows the structure of this XML field, and the table following describes the fields in this structure.

The structure of the SPEventsField

Note: The sample values are based on a list item created in a list located at http://portal.denallix.com/K2Learning/Lists/SharePointEventsList
Field Value Stored Sample Value
Type The Content Type of the item ListItems
Item (repeating node) This is a repeating XML node. Multiple Items can be listed under this repeating node.
ID The index of the current item in the Item repeating node 1
SiteURL The URL of the site where the item list is located http://portal.denallix.com/K2Learning
ListURL The relative URL of the list where the item is located.

The URL is relative to the Site where the list exists.
Lists/SharePointEventsList
FolderURL The name of the folder where the item exists. If no folder the Item ID is used. TestFolder

or
2_.000
Item The ID of the item that started the process 2
URL The full URL to the item.

Can be used as a hyperlink to open the Display Page of the item.
http://portal.denallix.com/K2Learning/Lists/SharePointEventsList/DispForm.aspx?ID=2
Source (Not relevant for the SharePoint Events process wizard)

EventDetails

The EventDetails XML datafield added by the wizard represents details about the event that caused the workflow to start. The structure of this XML field is shown in the screenshot below, and the table following describes the fields:

The structure of the EventDetails Field

Note: The sample values are based on a list item created in a list located at http://portal.denallix.com/K2Learning/Lists/SharePointEventsList
Field Value Stored Sample Value
Scope The scope at which the event occurred (e.g. ListItem or List) ListItem
EventType The event that caused the workflow to fire ItemAdded
SiteURL The full URL to the site where the list is defined http://portal.denallix.com/K2Learning
SiteRelativeURL The relative URL of the site where the list is located, relative to the Root Site URL of the Site Collection /K2Learning
List The Name of the list where the list item was created SharePointEventsList
ListRelativeURL The relative URL of the List where the item is located.
The URL is relative to the Site where the list is defined
Lists/SharePointEventsList
ListFullURL The full URL of the List where the item is located. http://portal.denallix.com/K2Learning/Lists/SharePointEventsList
ListItem The ID if the list item that started the process 2
ListItemTitle The title of the list item that started the process Test Item
ListItemRelativeURL The relative URL of the list item that started the workflow.

The URL is relative to the Site where the list item is defined.
Lists/SharePointEventsList/2_.000
ListItemFullURL The full URL to the list item that started the workflow.

This link can be used as a hyperlink to open the List Item display form.
http://portal.denallix.com/K2Learning/Lists/SharePointEventsList/DispForm.aspx?ID=2
Folder The folder where the list item is saved.

(If no folder, the list item ID is used, as shown here)
TestFolder

or
2_.000
Fields Stores the BEFORE and AFTER metadata values of the Item in two separate fields in CDATA format (Depends on the Item’s Metadata)

Fields Added by the Item Reference Wizard

Structure of the Content Field/Item Reference Field

Field Value Stored Sample Value
Type The Content Type of the item Documents
Item (repeating node) This is a repeating XML node. Multiple Items can be listed under this repeating node.
ID The index of the current item in the Item repeating node 2
SiteURL The URL of the site where the item list is located http://portal.denallix.com/K2Learning/300.HLP
ListURL The name of the List where the Item exists Shared Documents
FolderURL The name of the folder where the item exists Demo Folder
Item The Name/Title of the Item in SharePoint My Document.docx
URL The full URL to the item http://portal.denallix.com/K2Learning/300.HLP/Shared Documents/Demo Folder/My Document.docx
Source If this item was copied from another item, the source will contain the original item’s details in the same structure. This can be used to delete or otherwise modify the original item after creating a copy of the item.

 

 

January 22, 2012

Code-free table in email from SmartObject – Method B

Filed under: General,K2 Blackpearl — hoshy @ 1:08 pm


Thanks to Eric Schaffer from K2 in the US for this method!
 
Another code free way to do this is using XML and XSLT. The nice part about this approach is that you only make 1 SmartObject call. The tricky part is that you need a bit of XSLT understanding (which is borderline coding) but there is a nice tutorial here:
 
The basic idea is that you use a SmartObject event to call the get list method and map the values to a repeating XML field and then using a the XLST option on the data event you transform that XML field into HTML:
 
Here are some screenshots
 
 
 
 

Code-free table in email from SmartObject – Method A

Filed under: General — hoshy @ 12:56 pm
I got this question from another client.  Now, we all know that code is the way forward here.  As it’s Friday I thought I’d have a bash at doing it with no-code, and in fairness, it’s not so bad… and with some of the conditional events techniques it could be combined into a single activity too.  Performance is 1 SmO call per table cell + 1 – i.e. not good.

There is a another method using XSL that is much better performing – I will make a blog abou that too.

And a couple of screenshots:

Note – that behind the scenes of the first activity you need to configure an advanced destination rule “plan per slot” to configure the multiple instances (loop).

The basic principle of operation for this method is that the first activity runs onces for each row of the table – each time it runs it adds to the HTML table datafield, then the second activity adds some extra html around the main table body, and sends the email.

First data event:
Second data event:
Mail event:
Result:
Happy no-coding.

July 20, 2011

Embedding Office Web App frame in a SharePoint page, dynamically

Filed under: General — hoshy @ 12:28 pm

I was looking for a way to embed a Word document in to my SharePoint page.  It seems the with Windows Live, this is allowed – but what if the documents are stored locally on a SharePoint 2010 Serve with Office Web Apps enabled? No. The URL doesn't allow for embedding, it detects the iframe and gives an error.

Looking around I found this post, it describes how to use the source of the WordViewer.aspx to grab the iframe for the actual document, this will then allow you to embed the document, but there is a problem.  The source for the iframe is a URL that looks something like this:

http://portal.denallix.com/Sites/DocumentApprovalCase/WordViewerFrame.aspx?d=F01fa671c0367476c94cf7159cdd4363eme27788ac7945483ab227dcbf558bce4fme45d2577bbde4734aa37e73babe4af3bm&source=http%3a%2f%2fportal.denallix.com%2fSites%2fDocumentApprovalCase%2fDocuments%2fProjektverfahrensanweisungen.docx

Now in my case I had a dynamic SharePoint site that needed to be provided a parameter for which document to display. At first glance it seems simple to URL encode the source parameter and easily embed any document.  This is not the case.  What's actually going on is that the 'd' parameter is an encoded reference tot he document location and it's this that must be set correctly.

I embarked on a little session of Reflection (big R for Red Gate, not little r, where I might contemplate my life as a rock star).

I discovered that the requried 'd' parameter is simple a concat of four GUIDs of the site, web, library, and file IDs, prefixed with an F (O for a folder).

Internally MS's code refers to this encoding as a "String Representation".  Here's some example code for the SharePoint Object Model to generate it from a URL, via an SPWeb.  You should probably choose a better way to implement this but here are the fundamentals:

    public class OfficeWebAppUtil
    {
        public static string GetWordViewerURL(string url)
        {

            url = HttpUtility.UrlPathEncode(url);

            using (SPSite site = new SPSite(url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPFile file = web.GetFile(url);
                    string rep = StringRepFromItem(file);
                    return web.Site.Url + "/_layouts/WordViewerFrame.aspx?d=" + rep;
                }
            }
        }

        protected static string StringRepFromItem(SPFile item)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("F");
            builder.Append(item.Web.Site.ID.ToString("N"));
            builder.Append('m');
            builder.Append(item.Web.ID.ToString("N"));
            builder.Append('m');
            builder.Append(item.UniqueId.ToString("N"));
            builder.Append('m');
            return builder.ToString();
        }
    }

As for the soruce parameter – you might want to append that also as this is where you will be redirected to if you close the document or click the popout icon.

I'm sure the same technique will work for other document types.  If I get some time I'll wrap this in to a web part that can handle different document types… maybe :)

Cheers,

Hoshy, the K2 Pirate ;-)

May 20, 2011

Problems signing up to the mailing list?

Filed under: General — hoshy @ 11:20 am

Use the web interface: http://hoshy.co.uk/cgi-bin/mailman/listinfo/k2tech

May 18, 2011

K2 Blackmarket: Process Instance Version Migrator

Filed under: General,K2 Blackmarket,K2 Blackpearl — hoshy @ 10:44 am

Hello!

I want to tell you about an underused tool in the K2 Blackmarket community arsenal: The Process Instance Version Migrator.

This tool allows you to make inflight migrations of process instances between process versions.

It uses an API called LIM - Live Instance Management.  This API /is/ a K2 Supported API however the tool itself is community supported.

Credits for this tool go to Neil Maartens – A K2 Consultant now working in the US.  K2 Underground username: NeilM

So – on with the tool.  Download it from here: http://www.k2underground.com/groups/process_version_migration_utility/default.aspx

Extract the tool – full source code is included however you'll want to navigate to the folder: ProcessInstanceVersionMigrator\ProcessInstanceVersionMigrator\bin\Debug

Here you'll find a .exe which is to run the program and a .config thatcontains the server connection strings.

FIRST MODIFY THE .config

You'll need to modify the following:

<add key="K2SqlConnString" value="Data Source=localhost;Initial Catalog=k2server;Integrated Security=True;MultipleActiveResultSets=True"/>
<add key="K2ServerName" value="localhost"/>
<add key="K2ServerPort" value="5555"/>

By default the tool will work best if you're running on the (a) K2 Server as the K2 Server Service account.

Next run the tool .exe

Use of the tool should be quite straight forward.  When it runs you are presented with a window that describes 7 steps – each with a button associated.

Step 1 – Check the config file!

Step 2 – Click "Get list of processes" – this populates a drop down list with the process types on the specified server, select the process type you with you migrate.

Step 3 – Click on "Get Active Instances" – this will fill the table with a list of running instances of the selected process type, including the status and version of the instances.

Step 4 – Select each instance you wish to migrate – processes in error state can be migrated also.

Step 5 – Click on "Get process versions" – this will load a list of versions for the selected process type – then select which verson you wish to migrate the above instances to.

Step 6 – Click on "Get process version activites" – this loads a list of activites in the selected version that you can then select.  The tool will then perform a goto to the selected activity after migration. You can also choose not to redirect at all, or redirect to the current activity if you want to rexecute the current step (useful if the instance is in error and you want to restarted from the failed point).

Step 7 – Perform the migration!  This is the final step and the act can not be un-done.  By now you should have thoroughly tested the migration scenario in you test environments.

The table will show Migrating, followed by Migrated for each selected process instance.

Good luck!

P.S: Some other things to know.

  • There are only certain things you can chance and expect migration to work
    • See product documentation: Designers > K2 Designer for Visual Studio > Live Instance Management > LIM – Sourcecode.Workflow.Management > Important Notes
  • I have tested this tool myself on version from late 0807 (release of API) to 4.5 1320 (Latest at time or writing)
  • You can migrated backwards or forwards
  • <todo… suggestions welcome>

Cheers,

The K2 Pirate

March 26, 2011

Custom SSRS Code in external assembly (Resolve AD usernames to displaynames for reports)

Filed under: K2 Blackpearl,SSRS Reporting — Tags: , , — hoshy @ 10:24 pm

A common requirement in reports is to display the AD display name of a user rather than their username.  Ashley Evans, rather than DOMAIN\ashley for example.

There are of course a few ways to do it, but sometimes you just need to get the display name in the report and not worry about the rest of it.

This is where the attached code comes in to play.  It's a .net assembly that simply resolves a username to a display name, what's special about it is that it's strongly named, and includes the required code access security configuration to allow it to be used from within Reporting Services.

You can use it as it is, or just as an example of how to call custom code from SSRS.

There's one static method that takes a username in one of the following formats, and returns the display name.  If it fails for any reason it simply returns the input data allowing at least something sensible to be displayed in the report.  It's also multi-domain aware.

Input formats:

  • SecurityLabel:DOMAIN\Username (e.g. K2:DOMAIN\Username)
  • SecurityLabel:Username
  • DOMAIN\Username
  • Username

To use it you'll need to GAC the assembly in the attached project and deploy the CAS configuration to both the rssvrpolicy.config and/or rspreviewpolicy.config files.  The former allows the assembly permission to be loaded from SSRS for running the reports and the latter is for previewing the reports in Visual Studio 2008.

The default locations of the config files are:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\rspreviewpolicy.config
C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin\rssvrpolicy.config

The required CAS configuration for the policy config files is in the attached project in a file called: report server.config

It should be placed just above the final two closing </CodeGroup> tags.

To use the code.  Add a reference in your Visual Studio report project as follows:

Then in the field where you want to do the lookup, configure an expression similar to this:

=SSRSADInterop.ADLookup.UserDisplayName(Fields!Originator.Value)

Hey presto.  It works.

If you get errors, check the CAS configuration – it can be a bit fiddly to get working.  Ok, that's an understatement – it took me bloody ages the first time!

Have fun,

Hoshy, the K2 Pirate ;-)

Code: SSRSADUserLookup v1.0

New K2 Tech mailing list!

Filed under: General — hoshy @ 12:57 pm

Join the new K2Tech mailing list by clicking here to send a mail to the list subscription address Click here

Also visit the K2Tech archieves: Here

March 19, 2011

Hello K2 Blog

Filed under: General — Tags: , — admin @ 1:33 pm

Hello!

Welcome to my blog.

Over the coming months I'll be using this spot to communicate idea, best practices, code and insights in to all things K2 related.

Powered by WordPress