Stumbling Through: K2 Blackpearl (Smart Objects - Part III)
We left off previously with a well-defined smart object containing all of our asset properties and methods to create each type of asset. Now, we need to make a place to consume this smart object. I am choosing to use InfoPath, though Blackpearl can integrate with ASP .NET just as well. Time permitting, I will do this project in both, but the InfoPath -er- path seems easiest for our goals right now. So what we want to do is create an InfoPath form that first prompts the user to select an asset type, and then, depending on the type selected, fill in values for the columns of the selected type. When done, the user will click 'Ok' and the asset will be created with a status of 'Requested', and it will be sent to an 'Asset Administrator' for approval. Now this isn't a post on 'Stumbling through InfoPath', so I'm not going to go into much detail on the InfoPath form... I made it as quick and dirty as possible just to get it out there. I didn't create any logic, I simply created the input fields and plopped an 'Ok' button on it. I want to see just how much the Blackpearl integration with InfoPath with do for us. So let's assume we've created this form and saved it on our local (development) machine. We'll go back into our Visual Studio project, and add a new workflow called 'RequestAnAsset':
We need to tell this workflow that it will be integrating with InfoPath, so the first thing we need to do is drag out an 'InfoPath Integration' wizard:
I will now walk through each step of the integration process:
Click 'Next' to start the process. In the first step, simply add a reference to the InfoPath form that is stored on your local drive:
It will then ask where to publish the form when the project is deployed. I didn't make a space on SharePoint for these forms, but thankfully the wizard gives us the option to create a new space:
Click 'Next' and we are prompted to specify which Smart Object methods will be integrated with the form. Well, we want to form to be able to create any one of our asset types, so lets add all of our 'Create' methods. I am browsing through the context browser for our smart object methods like this:
But it is not allowing me to drag the method to the 'Method' entry field... I wonder if the Smart Object needs to be deployed before I can integrate with it? I went back to the Smart object definition and deployed it, accepting the defaults in the deployment wizard:
Let's try again to integrate with InfoPath. This time, though, make sure to browse for the forms library we created instead of creating another one:
When we are integrating the methods, we should now be able to drill into our smart object in the 'SmartObject server' section instead of the 'Local' section. At first, I didn't see anything different but as we learned previously, we should refresh the context browser before throwing the mouse through the monitor:
Add and drag each of our Create methods:
Click 'Next' and the wizard now asks us if we want to us a custom task pane for the form template. Hell if I know! I'll select the K2 Blackpearl task pane and make a note to ask somebody what exactly this means, though it may become obvious as we progress through the deployment:
By the way, if you do not see that task pane as an option, it may not have been deployed to your SharePoint site. This was a confusing part of the Blackpearl deployment and integration process, so I'll give you a hint: Log in to your SharePoint server's central administration site and click the 'Operations' tab. Under 'Global Configuration', select 'solution management'. Click the k2worklistwebpart.wsp file and deploy it in the resulting menu.
Let's get back to our workflow process, where we want to click 'Finish' to close out the smart object binding wizard. We are now back to our InfoPath Integration wizard with the smart objects bound to our InfoPath form. Let's click 'Next' and see what else it wants from us:
It is asking us which view of which form starts the workflow. Since we only have one form and one view, this is an easy one to answer. It is also asking us to specify a 'Process Folio'. I am not clear on what this means, but it isn't required so let's skip it. We should be able to accept the defaults for the 'Advanced Settings' screen, and the next step is the final step:
Would we like to configure a client event now? Sure! Check the box and click 'Finish' to start the InfoPath client event wizard:
Click 'Next' and it begins by asking us to name our event and specify the InfoPath view and form to use. We can name it whatever we want, and the view and form options are no-brainers (there is only one form with one view to choose from). 'Task Action Field' is a little ambiguous, let's leave it blank for now and see what happens. Click 'Next' and it asks us if we want to send a notification of the event to the end user. Check the box, it will be helpful to know that our event is working correctly. Click 'Next' and we are prompted to configure actions. I guess this is where we specify that whomever gets notified of this request needs to Approve or Decline the request, so we'll make those our actions:
Click next, and it asks us to configure outcomes. There are only two outcomes to this event, either the request is approved or it is declined. Since we had the checkbox checked on the previous page, it automatically created those for us:
That's convenient, click 'Next' and it prompts us for the 'Destination Users'. These are the users that will be notified of the pending request approval. We should make a group for those users, but for now, just put yourself in there:
Click 'Next' and then 'Finish' to create the client event.
So here is what it gives us:
Note that it included our InfoPath form with the project. The form is now being managed by K2, which is pretty useful as we'll get version control and K2 integration automatically.
Now what was completely missing here is how the heck do we tie the InfoPath fields to the SmartObject values? Or, I guess the more accurate question would be how do we invoke our 'Create' methods from InfoPath with the values the user entered into the InfoPath fields? I was hoping the wizard would encompass some of that. Before we answer that question, lets tie some events to the 'Approve' and 'Decline' outcomes of the client event and deploy our workflow. I'll just have it send me an e-mail in either case, just to have something valid out there. The process for doing so is straight forward using the 'Mail Event', so I won't cover it in detail:
Deploy this and select the default deployment options. Whew! All right, well, we covered a lot of material here but didn't get any closer to our goal of integrating with InfoPath; at least not on the surface. We need to figure out how InfoPath interfaces with our SmartObject methods, and how the values the user specifies can become property values of said SmartObject methods. Stay tuned, and we'll stumble our way through that (I hope).