Association

In one of the advances meeting, the consulting company tells you that he needs to save with which currencies each company works with. In order to do that you have to import an XPZ named ‘WWPTraining_CompanyCurrency’ which contains some objects and 2 transactions:

  • Currency: represents the currency information
  • CompanyCurrency associates a currency with a company.

It is necessary to have a form which provides the possibility to associate to some company the currencies which he works with.

WorkWithPlus provides the Association and Association Selection objects for that. Every time that you have a table structure like the one displayed in the following image, you can use the objects mentioned above.

Association_img01

In first place, create an Association object in order to associate the currencies to some company.

In order to do that you have to open Company transaction, go to its WorkWithPlus instance and make click in + icon --> Add --> Association. Then select the related transaction (CompanyCurrency in this case) and continue. WorkWithPlus will create a new object within Company’s instance named Association.

Association_img02

Association_img03

Association_img3.5

To establish how the lists of associated and non-associated records are going to be displayed, we have the properties Associated Records Expression, Associated Records Condition and Order List

The Associated Records Expression property defines what will be displayed in the lists (we can put an attribute, an attribute with concatenated text or whatever we want).

The Associated Records Condition property is for filtering, for example if there are records with logical deletion where there is an attribute that indicates whether the record is active or not and we want to filter based on that condition.

The Order List property is how these lists are going to be ordered: if we put an attribute in the expression we can use Use order clause, but if we put attribute + space + attribute we can use Order programmatically, which loses performance because it brings them all in a certain order and then order them in the client. The other option is to put False, which means that it shows them in the order in which they come from the database.

Then, it is necessary to add an action in CompanyWW that calls the new object, sending by parameter the identifier of the Company (CompanyId). Add this action in a new ActionGroup of type Combo inside the grid.

Association_img04

Association_img05

Before testing at runtime create a user action in the Company Selection object, next to Export to PDF action which initializes the currencies in the system. This action will call the procedure CreateCurrencies that was imported in the XPZ. Then run the application and visualize the results:

Association_img06

Click the action to Create Currencies and then go to associate currencies to some Company:

Association_img07

Now you can select the currencies associated to the selected company and press ‘Confirm’.

Association_img08