Symptoms
We are using an Item reference to populate fields in various workflow events. This item reference was created via the SmartForms Integration Wizard in K2 Designer for Visual Studio. The form submittal will start our workflow. However, we see that when we start the workflow that any fields used in these events from the Item Reference are not populating. E.g. pulling these fields into an email event body shows them not passing in any values.
Diagnoses
When we view the Item Reference in the Server.ProcXml table of the K2 DB we see that the Item reference has not been given an ID and it does not contain the necessary data from the item reference. It says that it has a previous id = 0 and no properties for the smartobject are given to it.
We remapped the smartobject being used in the item reference to ensure that it had the most recent version of the smartobject and ensured that the mapping was correct.
Smartforms Integration wizard was run again and we deleted and recreated the existing item reference.
I found that if we did an update method before the workflow started on that smartobject instead of a create method that the item reference would populate. Only difference here is that we specified the ID in the Update method. I changed the update method back to Create and then was sure to hold onto our ID somewhere on the form.
This same behavior is seen when creating a workflow in K2 Designer with a form starting this workflow. This is therefore a general rule of thumb when working with item references
Resolution
We are able to get this to work only if we specify the Smartobject ID that we want used in this item reference on the form. This can be hidden and so far we have seen this works when in a data label or text box control. We did this by setting a control's value to the output ID of the Smartobject Create Method that is run before the workflow starts action. After setting the ID on the form in a control when we run the workflow it will now populate with the correct information as expected.
Documentation request was submitted to update existing documentation on item references and include a note that the ID has to be specified in order for the smartforms integration to pick this ID up and use it in the item reference.