Meta Types

I had some interesting USE CASE’s to solve. Database MetaData proved to be the answer.

For ease of use I created these in the Database MetaData Editor, but any way they are created and applied to the database would have obtained the same result. Alter table modify constraint metadata  would do the same job.

What I show below is the metadata I created.

1) I had a caption for a field, nAcctBalance, that had to change based on the value of another field, lHasBalance

I first accessed the MetaData Editor for the nAcctBalance field by doing to the Data section, selecting the table and then the field, and then selecting MetaData Editor from the “gear” menu for the fields dialog.

Code:
formitem.caption=[lHasBalance]Balance,Balance Not Used

In the editor the 3 entries would be (showing | to indicate the sections):

Code:
formitem.section | lHasBalance | Balance,Balance Not Used

2) the same field, nAcctBalance, which had to be made not Editable when lHasBalance was .T.

Code:
formitem.editable | lHasBalance |TRUE,FALSE

Notice the use of oData-style .T. and .F.

3) make the data of nAcctBalance invisible when Balance Not Used

This could have been fancier, but works here:

Code:
formitem.dataForeColor | lHasBalance | Black,White

Refreshing the app shows the MetaData effects.

The beauty of this approach is that conditionals can’t be used in the attribute inspector but can in Metadata.

And it refreshes instantly (when lHasBalance is checked or unchecked), even when adding a record and changing the value of lHasBalance. No refresh is need for the conditionals to apply.

This is astounding, really, beyond belief. I have focused on working with Metadata for 21 years and never dreamed of anything this powerful.

In our VFP app, we end up writing methods to run on a Refresh to make these kinds of things happen. We can handle of number of things dynamically, but here we have the ability to use it for every attribute the object has.

This is magic!


Q:

is possible to manipulate MetaType from code?
for example add or modify?

A:

whether you can create or modify the metatype files created by the MetaType Editor programmatically the answer is no.

MetaTypes created with the MetaType Editor and MetaDafa attached to databases, tables and columns are two completely different things.

MetaTypes belong to the UI whereas

MetaData belongs to data.


In Lianja 3.4 as stated in the roadmap:

  • Added a graphical MetaData Editor for Database, Tables and Columns. Click the “Edit” icon in the ActionBar to show the MetaData Editor. You can find information on how to use MetaData here.

Name:  Screen Shot 2017-02-21 at 3.06.21 PM.jpg Views: 66 Size:  67.8 KB

MetaData and MetaTypes are two completely different things. MetaData system in Lianja is designed to reduce coding and simplify data design.

 


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s