Custom properties for business objects

Next month we are planning on upgrading to the v.14 of the Lansa Framework. I have no real idea of how much has changed, so I am still making notes that may or may not be relevant anymore.

This is related to the WAM Visual Lansa Framework Designer, where there is a nice setting to enable the configuration of filters and command handlers, based on custom properties set on each business object.

bo-custom-prop.png

Then, in the code I can retrieve that value with

Invoke Method(#avFrameworkManager.avGetUserProperty) Atlevel(B) Withname(MENUPUNKT) Alphavalue(#XTYPE)

This way I can set a different value, or groups of values, depending on which application the business object is a part of.

Using the instance list

In VLF, the standard layout consists of the menu (with applications and their sub-business objects), the filter, the instance list and the command handler. The instance list is set in the VLF designer, where the sequence and types are set.

The instance list has to visual identifiers (VisualID1 and 2) that are used as GUI keys, directed at the user, and a number of numeric and alphanumeric keys (Nkey1+ and Akey1+). Then there is option of 10 alphanumeric values (AColumn1-10), 10 numeric values (NColumn1-10) and 5 date values (DColumn1-5) – and more can be added, if you really need to. The visual GUI keys are also used in the header for the command handler.

Adding to the instance list is often done from the filter, as in

Invoke Method(#avListManager.AddtoList) Visualid1(#OPSID.AsString) Visualid2(#ITEMID) Nkey1(#LISTCOUNT) Nkey2(#OPSID) Nkey3(#COUNT1) Nkey4(#COUNT2) Akey1(#RECNAME) Akey2(#SNAME) Akey3(#ART) Acolumn1(#RECNAME) Acolumn2(#SNAME) Acolumn3(#ART) Ncolumn1(#COUNT2) Ncolumn2(#PRICE) Ncolumn3(#TOTAL)

surrounded by an appropriate use of

Invoke Method(#avListManager.BeginListUpdate)
Invoke Method(#avListManager.ClearList)
Invoke Method(#avListManager.EndListUpdate)

Updating an instance is done by

Invoke Method(#avListManager.BeginListUpdate)
Invoke Method(#avListManager.AddtoList) Visualid1(#OPSID.AsString) Visualid2(#ITEMID) Nkey1(#LISTCOUNT) Nkey2(#OPSID) Nkey3(#COUNT1) Nkey4(#COUNT2) Akey1(#RECNAME) Akey2(#SNAME) Akey3(#ART) Acolumn1(#RECNAME) Acolumn2(#SNAME) Acolumn3(#ART) Ncolumn1(#COUNT2) Ncolumn2(#PRICE) Ncolumn3(#TOTAL)
Invoke Method(#avListManager.EndListUpdate)

which will either insert a new instance or, if the keys match an existing instance, replace an instance.

Then, in the command handler the selection can be read with

Invoke Method(#avListManager.GetCurrentInstance) Visualid2(#ITEMID) Nkey1(#LISTCOUNT) Nkey2(#OPSID) Nkey3(#COUNT1) Nkey4(#COUNT2) Akey1(#RECNAME) Akey2(#SNAME) Akey3(#ART)

Thus values from the selection in the instance list can be passed to the command handler. If other values need to be passed from the filter (or other command handler) to the command handler, it can be done using the save and restore, like:

Invoke Method(#avFrameworkManager.avSaveValue) Instance(15) Withid1(CHOICE) Fromavalue(#CHOICE)
Invoke Method(#avFrameworkManager.avRestoreValue) Instance(15) Withid1(CHOICE) Toavalue(#CHOICE)

Notes in sizes:
VisualId1 and AKey1 to AKey5 are alphanumeric 32
VisualId2 is alphanumeric 50
NKey1 to NKey5 are signed 15,0
AColumn1 to AColumn10 are alphanumeric 100
NColumn1 to NColumn10 are signed 30,9
DColumn1 to DColumn5 are alphanumeric 19

Environment variables

I have some trouble finding the correct builtins, so when I finally find it, I have to make a note. Like, if I wanted to see the username of a user logged on through RDP:

Define Field(#VALUE) Type(*STRING) Length(28)
Define Field(#RC) Type(*STRING) Length(2)
Define Field(#VT) Type(*STRING) Length(1)
Use Builtin(GET_REGISTRY_VALUE) With_Args('HKEY_CURRENT_USER' 'Volatile Environment' 'USERNAME') To_Get(#VALUE #RC #VT)

So now I have learned to use the GET_REGISTRY_VALUE builtin. Actually, I wanted to find the CLIENTNAME value, but the registry path to that is Volatile Environment\ENVID\CLIENTNAME where, apparently, ENVID updates on every connection.