This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided “as is” with no warranties.

Objective

In this tutorial we will go over how to create a composite SmartObject that is created from two separate SmartObjects allowing you to use this single composite SmartObject but getting the getting data from two separate SmartObjects. We will be using a SQL SmartObject and an Oracle SmartObject, but this can be done with SmartBox SmartObjects as well.

Before You Begin

Make sure you have a SQL and Oracle SmartObject ready that each have a key property field and a one to one relationship. Have Visual Studio open and ready.

How-to Steps

1. Open a new K2 SmartObject Project in Visual Studio. This will open a blank SmartObject with the prepopulated methods.

2. At the top, right above where you can name the SmartObject, click 'Advanced Settings'. Go to the SmartObject Methods and select 'Remove All' to delete all the existing methods.

3. Still in the SmartObject Methods section, select 'Add' to add a new method. When the wizard pops up check the Advanced Mode box and select Next. This will be our advanced list method that pulls from two separate SmartObject methods.

4. Name the method and click next and next again. In the Service Object Method screen, click 'Add'.

5. Click the ellipse next to the Service Object Method box which will bring up the context browser. Expand the ServiceObject Server(s) node and find the Service Object of the primary (SQL) SmartObject. Expand that to get the available methods and select the List method.

6. It should now be asking you to configure the Input and Return properties for the method. Select 'Create All' and click OK to continue.

7. You should now see the properties of the first SmartObject show up in the background. Click Add again on the Add Service Object Method wizard as before, expand the ServiceObject Server(s) and drill down to the secondary (Oracle) SmartObject Service Object.

8. Choose the List method again and select 'Create All' to bound the input and return properties. Click OK and you should now see the remaining properties show up in the background. Click Next.

9. Now we're going to Setup the Service Method links to tie the two ID properties together. Click 'Add' at the top.

10. Choose the primary SmartObject Service Object Method, keep the link type to 'Matching values in both objects'. Then choose the secondary SmartObject Service Object Method in the bottom drop down.

11. You should see the primary (SQL) SmartObject properties in the box, select the ID property and select 'Assign'. From the drop down choose the ID property of the secondary (Oracle) and click OK. This will bind the ID properties together.

12. Click OK and Finish. Deploy the project and you will now have a composite SmartObject that can be used anywhere a SmartObject can be used.