Skip to main content

I have an InfoPath form that users would like to be able to query data from.  The only ways I've found to make this possible are to put the data in a SQL Database or into a SmartObject SmartBox.  I haven't been able to successfully implement integration with a SQL database because the form is browser enabled and can't submit through the web.  So, on to the SmartObject.  I created the SmartObject which is made up of 5 SmartBox tables.  I tried to connect the SmartObject using the SmartObject integration but it appears this is only for looking up items from the SmartBox, whereas I need to write items to the SmartBox.  The tables are as follows:


Requisition (stores general data about requisition)


Items (stores line item details - can be many items per requisition)


Approvals (stores details on who has approved form - can be many approvals per requisition)


Supplier (stores supplier information - only 1 per requisition)


Evaluation (stores information on parts evaluation - only 1 per requisition)


 


 Anyone have any ideas how I can do this?

Sounds like you are binding your text boxes to the SmartObject GetList method.  You should be binding it to the SmartObject Create method if you want to do inserts.

I believe that you should also be able to use code in a server event to store the info path data using the SmartObject API.

 

SmartObject smartObject = serverName.GetSmartObject("Requisition")

smartObject.Propertiess"PropertyName"].Value = "Value to assign"

 

see "How to add data to a SmartObject" in the K2 2blackpearl] developer reference

 


I added only the "create" method so I don't know how i would be binding to the GetList method.

If you are using the Create method, that should be correct.


Once you integrate the SO Create Method, you should see it in your data sources.  If you drag the node containing the input params to your form layout.  It should automatically create the input fields for you.


 Maybe you can include some screenshots to show us what you are doing.  Otherwise, it's a bit hard to tell what is going wrong.


ok, removed all the SOs associations to start anew.  Added the Create method to my form, shows up under secondary data connections.  How would I go about getting the data from the form to SmartBox as I can't run a "Submit" against a secondary data connection.  I also noticed when I add the create method the fields only show up under "query fields."  For grins, I attempted to enter some data and submit the form but it isn't writing anything to the smartbox.  Any help would be appreciated
16739i90D5FD9267523552.jpg

You will need to add an action when the IP form is submitted, else the IP form wont know when to call your "Create" method. If you use a button to submit:



  1. Right-click on the button and select "Button properties".
  2. Click "Rules".
  3. In the "Rules" modal, click "Add".
  4. Give it a name and click "Add action".
  5. Select "Query using a data connection" in the action dropdown and then select your Create data connection.
  6. Click "OK" all the back to your form.

If you are using the default "Submit" option of the form:



  1. Click "Tools" --> "Submit Options...".
  2. Check "Allow users to submit this form" and select "Perform custom action using Rules...".
  3. Click on the "Rules" button.
  4. Follow from step 3 above.

You can directly bind your form controls to the input fields of the SmartObject method data connection.  Alternatively, you can create your own rules to set the data into the input params.


 Either way, you can execute a custom action in your Submit Options to submit the data.  To do this, configure the rule rule to "Query using a data connection" (note do not use "submit using a data connection") on the SmartObject method.  This causes the web service call to execute.


ok, so here is where I encouter a problem.  I can get the SmO to write data to the SmartBox, however the problem is I need to be able to write to the Items table as a repeating table from InfoPath.  Basically, there can be multiple Items per Request, but I can only seem to write 1 Item per request.

One way is to go to code and loop through and execute the SmartObject methods for each line item upon the form submission.


There two places where you can do this.



  1. InfoPath form code behind.
  2. Submit the line item data as XML with the InfoPath document.  Once inside the process, you can then do a server event to loop through to insert each line item.

The is another cool codeless way from InfoPath (idea was provided courtesy of Jason Kleban).



  1. Put your line items as local fields in the main datasource in a repeating node.
  2. Create an additional dummy field and give it a value.  e.g. I create a field called "trigger" and give it a value of 0.  So all my line items will get created with this invisible field with value 0.
  3. In the Submit rules, create a rule to set this field to 1.
  4. In the data source browser, right click on the "trigger" field and select properties and then "Rules and Merge".
  5. Add a rule here on the condition that "trigger" field = 1.  Add an action to populate the other fields into the SmartObject method's input params and then call the "Query using a data connection" action to execute the SmartObject call.

You will notice that by setting the trigger field value upon clicking the submit, each line item will fire an individual action for each line item's data.


I have tried the codeless way and so far so good!  Thanks for all the help.

I was trying to follow your steps, but could not find the option in dropdown to 'Create data connection'


2861909478_1ef1f5542e_o.jpg


Am I doing something wrong here? 


Did I miss any step while creating the workflow or designing the infopath form.


Thanks in advance.


icon-quote.gifdc:



  1. Right-click on the button and select "Button properties".
  2. Click "Rules".
  3. In the "Rules" modal, click "Add".
  4. Give it a name and click "Add action".
  5. Select "Query using a data connection" in the action dropdown and then select your Create data connection.
  6. Click "OK" all the back to your form.

If you are using the default "Submit" option of the form:



  1. Click "Tools" --> "Submit Options...".
  2. Check "Allow users to submit this form" and select "Perform custom action using Rules...".
  3. Click on the "Rules" button.
  4. Follow from step 3 above.

OK, when you create your SmartObject there should be a "Create" method associated with it which, in the case of the dynamic sql service, will execute the "Insert Into" command against the database.  When you run the InfoPath Integraiton wizard in the workflow you will need to specify your SmartObject so the appropriate methods appears as data connections in the form.  Once you have the SmO added to the form then you will be able to query against the "Create" method of your SmartObject.  hope this helps.

Thank for your help Jason.


You are right. I missed the important step of integrating infopath form with SmartObject while creating my workflow.


Too bad I could not find this relevant information in K2 documentation. I had to find out from the K2101 training course material, which my colleauge had.


 


I tried Your solution and its works great. Thanks for your solution.


Hi,


I know this an old thread but hopefully someone can help me, I am using the codeless method above but the problem I have is how can I get / pass the Sharepoint List ID that gets created for each repeating table into Smartobject Load methods in my process so I can use specific line item values in my line rules ?


On form submit the line items are being written to the Smartobject (Sharepoint List SO in my case) & then the process begins, but I need to reference specific values from the repeating table within my process which requires me to pass each line item ID to the SO Load object in a IPC process so each line get processed through an approval system.  Any ideas how I can get each line item ID so I can process each one in my IPC ?


 


Thanks


 


 


 


**bump**


Reply