Update Instances

WorkWithPlus provides the possibility to update pattern instances from InstanceTemplate that were already created, by the 'Update Instances' functionality.

The Update Instances functionality has two main goals:

  •  Propagate changes made to a Template (Instance template or WebPanel Templates) to all the instances that are already created and customized. This changes could be adding a new node, modifying some property of certain node, reordering nodes, etc
  •  Propagate changes made to some transaction's structure. This changes include adding or removing attributes and relationship between transactions, or modifying descriptions of attributes or relationships between transactions.

In order to do execute the Update Instances functionality, there are two options:

Update all Instances of a template

The first one is to update all the instances that are created, and this process is irreversible. In other words, this is a batch process that will go over each instance, update it and save changes. That is why it is recommended to make a back up of the Knowledge base before executing this action.

If we want to execute this action to the instances related to transactions, we must do right-click over Instance Generation Template node and select the option 'Update Instances'. But if we want to execute this action to some webPanel's instances we must do right-click over the web panel template that we want to update its instances and select the option 'Update Instances'.

Update one instance in particular

The second option is to update one instance in particular. This process will not save the object, so we could visualize the modifications that the action made over the instance and reverse that changes or save them.

To execute this action we must open the transaction's instance that we want to update, and do right-click over the main node, selecting 'Update Instance' option. Or open the webPanel which we want to update its instance and do right-click over the main node, selecting 'Update Instance' option.

In both cases, the customization that user made to the instances will not be overwritten when executing this action. With customization we refer to insert new nodes, modify properties of existent nodes, move certain node's location, delete nodes, etc.  

Let's see an example over Person instance.

First, we have the following Instance template's structure and nodes:

GeneXus IDE WorkWithPlus pattern editor for the 'Country' transaction shows the structure tree with TableMain, TableContent, a General Information panel, Subor Levels Position, an Action Group with standard Enter/Cancel/Delete actions, intermediate and leaf sublevel nodes, attribute-based rules (audit and create/update date-user rules), and events. The live preview on the right renders a 'Country' form with Id, Name, Short Name, Phone Code, Create Date, Create User, Update Date, and Update User fields.

Now we create Person's instance, which will take its nodes, and the order of them from Instance Template, and will look like the following picture:

GeneXus IDE structure tree for the 'Transaction (Person) - Template: Main' pattern instance shows TableMain, TableContent, an Error viewer, and TableAttributes organized into Tabs: a 'General Information' tab with a Table listing PersonId, PersonNickname, PersonFirstName, PersonLastName, PersonCellNumber, PersonHomeTelNumber, PersonBirthDate, plus an Auditing panel (PersonCreateDate/User, PersonUpdateDate/User), alongside Additional Data and Emails tabs, an Action Group with standard Enter/Cancel/Delete actions, attribute-based rules, and a DoCommit event.

GeneXus IDE structure tree for the 'Selection (Person)' pattern instance shows TableMain, TableHeader with TableActions (Insert, Export, ExportReport, EditColumns), TableRightHeader with a ManageFilters action and TableFilters (Orders, Dynamic Filters), an Error viewer, and a Table/Grid node listing Person attributes (PersonFullName, PersonNickname, PersonBirthDate, PersonHobby, PersonGender, CompanyName, PersonCellNumber, and hidden PersonTeamFan/PersonHairLength/PersonHairStyle) with Delete and Update standard actions.

GeneXus IDE structure tree for the 'Prompt (Select Person)' pattern instance shows TableMain, TableHeader with TableFilters (Orders, a CleanFilters action, and Dynamic Filters offering StartsWith/Contains operators for PersonFullName and CompanyName), and a Grid with a Select standard action listing hidden PersonId plus visible PersonFullName, PersonNickname, PersonGender, and CompanyName attributes, ending with an InOut:PersonFullName parameter.

GeneXus IDE structure tree for the 'View (PersonFullName.ToString())' pattern instance shows a PersonId parameter, TableMain with TableTitle displaying 'Person::PersonFullName', a WWLink node, Tabs position setting, and a Tabs section containing a Tabular tab (General), Tabular tab (Auditing), and Grid tab (Email).

GeneXus IDE structure tree for the 'Tabular tab (General)' node within a View pattern instance shows a Table with an Error viewer and TableAttributes listing PersonId, PersonFullName, PersonNickname, PersonBirthDate, PersonHobby, PersonGender, CompanyId, CompanyName, PersonCellNumber, PersonHomeTelNumber, address and music-band related attributes, plus hidden PersonTeamFan/PersonHairLength/PersonHairStyle, followed by TableActions with an Action Group containing Update and Delete standard actions.

We can appreciate that 'Attributes' node from Instance Template where replaced with the attributes from Person transaction, and the same occurs with orders and filters. On the other hand, nodes like Standard Actions or TextBlock where transcribed identically because they do not depend on the instance like the case of attributes.

Now we make the following changes to Person instance:

GeneXus IDE pattern editor for the 'Person' transaction, on the Work With Plus tab, shows the structure tree with red callout notes: an arrow reading 'We moved table that contains attributes on top of ErrorViewer' pointing at TableContent, and another reading 'We remove StandardAction Delete to the ActionGroup' pointing at the Action Group with only Enter and Cancel standard actions remaining. The live preview shows a form with ID, Name, Address, Gender, and Age fields plus Confirm and Cancel buttons.

GeneXus IDE Properties panel for a textBlock control named 'PersonTitle' inside a Selection (Person) pattern instance shows its Caption property set to 'WorkWithPlus Modified' (highlighted yellow) under Theme class 'TextBlockTitleWWP'. A red callout explains that a new variable node named 'NewVariable' was added under TableActions and its Caption was changed to 'WorkWithPlus Modified' while other properties kept their default values.

Then we save the object, and we make the following changes to Instance Template: 

GeneXus IDE WorkWithPlus pattern editor structure tree shows a red arrow and callout reading 'We added a new TextBlock node' pointing to a newly added '<textBlock>' node placed under TableContent, above the 'Panel: Informacion General' node. The live preview on the right shows the 'Informacion General' panel header in the transaction form.

The GeneXus IDE pattern editor shows a Selection node tree with the 'New WorkWIth<TRN_DESCRIPTION>' TextBlock selected and its Properties panel open, Caption and Theme class edited to 'AnotherThemeClass'. Red callouts explain three instance customizations: modified properties including Caption, removal of the StandardAction Export from the ActionGroup, and the Grid node moved to the Table Actions.

Now we execute Update Instance action over Person Instance like we can visualize below:

The Person transaction's Patterns tab in the GeneXus IDE shows the WorkWithPlus pattern applied, with the Transaction pattern tree expanded. A context menu on the right lists 'Update Instance' (highlighted), 'Mark Instance as Updated', Preview, 'Open WorkWithPlus Settings', 'Apply Pattern Instance', and 'Build With These Only'.

We visualize the results:

The first thing that appears is a confirm panel which explains that StandardAction 'Export' of object Selection was deleted from WorkWithPlus Instance template. We should determine whether to delete this node from Person instance, or if we want to maintain it.

If we press 'Cancel' the process will be canceled and the instance will not be updated if we had executed the action for only one instance (like this case that we did rigthright-click over Person transaction node > Update Instance), but if we had executed Update Instances for all instances created (by doing rigthright-click over Instance Template > Update Instances) the process will be canceled but the instances which were updated and saved will not re reverted.

We also have the option to set for all instances which we are updating the same option we took, by checking the 'Select same option for all instances' button. This only applies when we execute Update Instances from Work With Plus Settings, but not when we update only one instance like this case.

A 'Node deleted' dialog in the WorkWithPlus pattern editor states: "The node of type ActionGroupStandardAction with key 'Export' of object 'PersonWW' was deleted from the default instance. Do you want this node to be deleted from Person instance?" It offers a 'Select same option for all instances' checkbox and Yes, No, and Cancel buttons.

We press Yes, in order to delete this Standard Action, and the process will continue. This confirmation will appear for every object that was deleted in Instance Template. In the example we delete only one node in Instance Template, so this confirmation will appear only once.

Then the following message will appear:

An 'Update Instance' confirmation dialog reads "The instances were updated succesfully" in purple text, with 'View log' and 'OK' buttons below.

Note: The 'View log' button only appears when the property Generate Log  of node 'Transaction Templates' within WWP Configuration object is True.

Now the instance is already updated from Instance Template. 

In Person instance, the modifications that we made before Updating it were:

  •      Move table that contains attribute on top of Error Viewer (in Transaction node)
  •      We remove StandardAction Delete (in Transaction node)
  •      We modified 'Caption' property of TextBlock node named 'PersonTitle'
  •      We add a new Variable node named newVariable, just after 'PersonTitle' textblock.

This modifications were illustrated in a picture above that shows Person's instance.

If we analyze the log, it is divided in four sections:

    - Properties not updated: specifies the properties from some nodes that were not updated because they 
      did not have their default value. In the example, this is the case of 'Caption' property from TextBlock 
      node named 'TitleText'.

    - Nodes with children disordered: specifies which nodes have their children disordered. In the example, 
      this is the case of Table 'TrnContent' of Transaction object, because we moved the table that contains 
      the attributes on top of 'ErrorViewer', and these nodes are inside 'TrnContent' table.

    - Deleted Nodes from this instance: specifies which nodes were deleted from this instance in particular. In 
      the example, this is the case of StandardAction 'Delete' of Transaction object.

    - Particular Nodes of this instance: specifies the nodes that were added to this instance in particular. In 
      the example, this is the case of Variable node (TableVariable), named 'NewVariable' of Selection object. 

A spreadsheet-style 'Update Instances' log lists results for WorkWithPlusPerson: Yes, broken into sections 'Properties not updated' (TextBlock 'PersonTitle' of object Selection, Caption not updated), 'Nodes with children disordered' (TrnTable 'TableMain' of object Transaction), 'Deleted Nodes from this instance' (ActionGroupStandardAction 'Trn_Delete' of object Transaction), and 'Particular Nodes of this instance' (TableVariable 'NewVariable' of object Selection).

Finally, we visualize the results in Person instance:

The Person transaction's WorkWithPlus instance tree and preview show three annotated update-instance behaviors: a Caption TextBlock node newly added by the Instance Template gets inserted into the instance, a previously removed 'TrnDelete' StandardAction is not re-added, and the TableContent node moved above the Error viewer in this instance is preserved (not overwritten) after updating.

The Selection pattern tree for object Person shows a 'WorkWithPlus Modified' TextBlock selected, with callouts explaining update-instance merge rules: the ThemeClass property updates from the template because it was unmodified while the Caption stays because it was customized, the Grid node moves outside onto TableActions per a template change, and a NewVariable node persists even though it no longer exists in the template.   

You can read more about this process in the following link: Update Instances Process