Delete attribute from all instances

WorkWithPlus provides the possibility to delete an attribute from all the instances created within a KB. This is useful when we have an attribute that is being referenced in many transactions as an inferred attribute for example, and at a moment we do not need it any more (we avoid going through every instance's transaction and deleting it manually, which save us a lot of time).

It is important to know that this functionality will delete all the appearances of this attribute in all the Work With Plus instances as an attribute node, but it will not delete the indirect references to this attribute like when they have variables based on it, or filters for example.

We will use attribute CompanyDescription as an example. As we can visualize below, this attribute is referenced by Company and Person Instances.

The GeneXus References dialog for CompanyDescription:Description lists objects that reference it under Is Referenced By, including Company, CompanyGeneral, CompanyPMCompanyPrompt, CompanyPrompt, CompanyWW, CompanyWWDS, Person, PersonWW, WebPanel, WorkWithPlusCompany, WorkWithPlusPerson, and WorkWithPlusWebPanel, with a Has References To panel on the right showing Attribute and Description.

We visualize Person Instance:

The GeneXus Patterns editor for the Person transaction, with Work With Plus applied, shows the structure tree under Basic Information (Tab1) including PersonId, PersonFirstName, PersonLastName, PersonFullName, PersonHobby, PersonNickname, PersonBirthDate, PersonGender, CompanyId, CompanyName, and a red arrow pointing to the CompanyDescription attribute.

The GeneXus Patterns editor for the Person transaction shows the Selection node tree with Dynamic Filters for PersonFullName and CompanyName, a Grid listing attributes including CompanyId, CompanyName, and a highlighted CompanyDescription attribute selected in the Grid list, followed by PersonCellNumber and other attributes.

We visualize Company Instance:

The GeneXus Patterns editor for the Company transaction shows the Panel: General Information node tree with attributes CompanyId, CompanyName, a red-arrow-highlighted CompanyDescription, CompanyUrl, CompanyLogo, CompanyLocation (Hidden), CompanyCreateDate, CompanyCreateUser, CompanyUpdateDate, and CompanyUpdateUser, followed by an Action Group with standard Enter, Cancel, and Delete actions.

The GeneXus Patterns editor for the Company Selection node shows TableFilters with a Dynamic Filters section; a red callout box states 'This is a filter based on CompanyDescription, and it will be deleted,' pointing to the highlighted Dynamic Filters condition line for CompanyDescription with Dyn. Operators, StartsWith, and Contains options.

The GeneXus Patterns editor for the Company View shows the Tabular tab (General) TableAttributes tree with CompanyId, CompanyName, CompanyUrl, CompanyLogo, CompanyLocation (Hidden), and other fields, plus a highlighted CompanyDescription variable node; a red callout states 'This is a variable defined as based on CompanyDescription. This variable will not be deleted.'

In Person's instance, it is being referenced by attribute nodes (in Transaction, Selection, Tabular Tab), but in the case of Company's instance CompanyDescription is referenced by attribute nodes within Transaction and Selection objects, and by a variable based on CompanyDescription as well as a filter. As we mentioned above, the variable and the filter will not be deleted automatically so user will have to do it manually.

We will execute the action from the WorkWithPlus menu. Right after we click on the option to execute this action, the following window will open in order to select the attribute we want to delete:

The Delete attribute from all instances dialog lists knowledge base attributes with Name, Module, Type, and Description columns, including CompanyCreateDate, CompanyCreateUser, CompanyDescription (highlighted), CompanyId, CompanyLocation, CompanyLogo, CompanyName, CompanyUpdateDate, CompanyUpdateUser, CompanyUrl, and several Country attributes, with Filters for Pattern, Object Type, and Object set to *ALL, and OK/Cancel buttons.

We select 'CompanyDescription' and press Ok:

The Delete attribute from all instances dialog shows the same attribute list as before, with CompanyDescription selected/highlighted in blue among rows including CompanyCreateDate, CompanyId, CompanyLocation, CompanyLogo, CompanyName, CompanyUrl, and Country attributes, filtered by Object *ALL, with OK and Cancel buttons.

A confirmation message will be shown:

A confirmation dialog titled Delete attribute from all instances asks 'Are you sure you want to delete attribute 'CompanyDescription' from all instances?' with Aceptar and Cancelar buttons.

After we confirm the action, the output window shows in which instances the attribute was deleted, and if occurred some problem during the operation. In the example of CountryDescription, the attribute was successfully deleted from both instances, but as the variable and the filter was not deleted, a message is shown so that user is aware of the situation and can identify the instances that still have references to the attribute. 

The GeneXus Output panel logs the result of deleting the CompanyDescription attribute from all instances, showing lines like 'Attribute from instance WorkWithPlusPerson was deleted', 'Processing instance WorkWithPlusCompany', 'Attribute from instance WorkWithPlusCompany was deleted', 'Attribute from instance WorkWithPlusWebPanel was deleted', a note that references from WorkWithPlusCompany must be deleted manually, and 'Delete attribute from all instances (CompanyDescription) Success'; a red callout explains this relates to a variable that must be deleted manually while the attribute node itself was removed correctly.

In some cases, a validation error can cause that an attribute cannot be deleted (for example, if an instance has a grid with only one attribute in it, and we try to delete it will could not do it). When this situation happens, a message will be displayed on output window, and user will have to open the instance and delete it manually resolving the conflicts.