Stumbling Through

Join me as I stumble, bumble and fumble my way through some new developer technologies. We'll laugh, we'll cry, there may be a mouse tossed through a monitor, but in the end we will all hopefully learn something.
in

Stumbling Through - K2 Blackpearl (Smart Objects - Part IV)

So where are we?  We have a fully defined SmartObject deployed on our SmartObject server, we have an InfoPath form and we have a workflow process that will tie it all together... the one thing that is missing here is the glue.  As with most things I've been stumbling into, the 'glue' turned out to be surprisingly easy to locate once I sat down and thought about it.  The only place that can tie an InfoPath form with data, would be the InfoPath form itself.  When I first created my form, though, I didn't see any way to bind it to a smart object.  However, after going through the InfoPath integration wizard and having my form become a part of the project, that may have changed.  Let's open up the InfoPath form from the Visual Studio project itself.  This brings it up in run-mode, but we want to be in design mode so click 'Tools -> Design This Form'.  When we visit the 'Data Source' section, notice that it is now populated with several datasources:  'Main' seems to contain the properties of our Smart Object.  Our 'Create' methods appear as individual data sources.  Two additional data sources are available as well, though their purpose isn't clear to me as of yet:

image

So I guess it was foolish of us to design our form before integrating it into K2, because now we can simply drag and drop the columns from our data source:

image

Now I dragged all of these fields out from the 'Main' data source, though I bet I'd have to use the ones from one of the 'Create' methods in order for it to work as we want.  However, we'll proceed with this and see what happens.  Save the design, then re-open the form from Visual Studio and submit it after entering in a few values.

When we go out to SharePoint and view our K2 tasks web part, we can see that it must have gotten at least to the part in our workflow that said to create the task:

image

However, visiting the 'Clarity Assets' list we see that it is still empty... our 'Create' method did not execute.  Since it hit our 'create K2 task' event, we can safely assume that it is a problem with our InfoPath form, which is likely because at no point did we tell it to invoke one of our 'Create' Smart Object methods.  While that may ultimately be true, I want to play around with another feature first to see if it will work too.  Let's add a 'SmartObject Event', making it the first thing to be invoked when the workflow starts.  We'll make this event call our 'CreateLaptop' method.  This is where we get a little constrained, as we can't tell it to call a different method depending on the type that was selected in the form.  Oh well, I just want to see if it'll work!  Here is what our workflow should look like now:

image

Deploy and then submit another request and... crap, that didn't create the list item either!  Let's remove that smart object event that we just added and get back to our InfoPath form, there has got to be some way to tell it to run our method on submit!  Not being an InfoPath expert, it wasn't very obvious to me to find the 'Tools - Submit Options' menu, but once I was in there it was pretty straight forward to add a rule that queries our 'CreateLaptop' method before it creates the workflow.  Now I believe I will also remove the fields we have in there and instead use the 'CreateLaptop' fields:

image

We can probably clean these up, I just want to see something working!  Save this new design and re-open the form.  Enter in some data and submit it:

image

Hold your breath, and check the Clarity Assets list...

image

Yes!  There it is!  I am going to go get myself a coke and give this new information some time to digest.  I will probably completely re-do the project now that I kind of know how things work, and will post a more 'correct' version for your reading pleasure.

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)