K2BTools Tutorial - Exercise 1.1: K2BEntityServices basic usage

Introduction

In this exercise you will learn how to use K2BEntityServices in GeneXus. K2BEntityServices is the main pattern in the K2BTools suite, and generates the base architecture upon which the application is built. Work With interfaces are built using this tool, as well as all interfaces needed to view, update or delete records for the transaction it is applied in.

In this exercise the pattern will be applied to the Country, City, Product, ProductStorage, and ProductUnits transactions. Then the generated application will be executed to see the end result.

Pattern application

1 - Apply the pattern to the Country transaction

  1. Open the “Country” transaction.
  2. Go to the “Patterns” part.
    PatternPart
    Pattern Part

  3. Enter the “Entity Services” tab.
    EntityServicesPatternTab
    Entity Services Tab

  4. Select the “Apply this pattern on save” option.
    ApplyPatternOnSave
    Apply Pattern On Save

  5. Save the transaction.

Note: The first time a pattern is applied, a set of GeneXus objects, called “Basic Objects” are imported in the KB. This objects are referenced in the generated code, and implement common features. For this reason, the first time a pattern is applied the process takes longer.

  1. Go to the KB Explorer in GeneXus, and find the Country transaction. Now, this transaction should contain the instance as a child object, along with its generated objects.
    PatternGeneratedObjects
    Pattern-generated objects

2 - Apply the pattern to the City transaction

In this case, you will perform some changes to the default configuration.

  1. Open the "City" Transaction
  2. Go to transaction properties to the K2BTools/Navigation category and set After Insert property to "Return To Caller"
    TutorialAfterInsertProperty
    After Insert Property

  3. Apply the pattern to the City transaction following the same steps followed in the previous section.
  4. WorkWith Node: Delete this node. After this deletion, cities will be accesible only through the Country Entity Manager.
    WorkWithDelete
    Delete WorkWith

  5. EntityManager Node: Delete the Customer SubWorkWith from this node.
    SubWorkWithDelete
    Delete SubWorkWith

3 - Apply the pattern to the Product transaction

After applying the pattern on this transaction, as seen in the first section, perform these changes.

  1. Delete the “ProductObservations” attribute from the WorkWith node.
    AttributeDelete
    Delete Attribute

  2. Delete the “Invoice Lines” SubWorkWith from the EntityManager.

4 - Apply the pattern to the ProductStorage transaction

After applying the pattern on this transaction, as seen in the first section, perform these changes.

  1. Delete the WorkWith node.
  2. Delete all Components inside the Entity Manager, except the “General” component. You should delete all the SubWorkWith and Parallel nodes.

5 - Apply the pattern to the ProductUnits transaction

After applying the pattern on this transaction, as seen in the first section, perform these changes.

  1. Delete the WorkWith node.

6 - Apply the pattern to the Unit transaction

Apply the pattern as seen in the first section.