We will make use of an example where different line of businesses can have multiple products in each line of business. In other words one line of business has many products, but a product can only be associated with one line of business, as depicted in the diagram below.
K2 Automated Testing Software
BenchQA allows full test automation of K2, including fully automated K2 SmartForms and K2 Workflow testing. It promotes test driven development for K2 and ensures continued quality assurance for K2 solutions. Easily apply changes to test cases to accommodate changes to K2 apps and ensure all apps are regression tested to avoid defects and assure continuous quality.
In this example we will create two SmartObjects and then add an association between the two objects. We have started off by creating the following two tables in the database:
We already created the LOB SmartObject, giving it the usual default properties and methods. The next step is to create the product smartobject, and configure its association to the LOB smartobject. We will briefly step through the steps required to accomplish this below.
1. Right-click on a category and select ‘New smartobject’. This will open SmartObject Designer wizard.
2. Click on next to skip the first step of the wizard (Introduction).
3. In the general tab specify a name for your smartobject, select Advanced SmartObject, and press next
4. Select the Methods Tab and press Add.
5. Select the Product table and press next.
6. Press Create All to create all the default properties, and press finish.
7. The next step is to define the association with the LOB smartobject. Press next, add, then select the LOB SmartObject from the list.
8. Now configure the one to many relationship.
9. And finally define the key for this relationship.
10. The highlighted section of thefollowing screenshot indicates that the relationship between the two smartobjects has been correctly defined.
Now that our SmartObjects have been created we can go ahead and use this association to easily create dropdowns, as we will discuss in a future article.