Salesforce

How Do I Define Reusable Data Objects? (Magic xpa 2.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Define Reusable Data Objects? (Magic xpa 2.x)

One of the challenges in creating large applications is keeping data fields consistent. For example, if you have an address field, you would not want it defined as 30 characters in one program, and as 40 characters in another program. If you have a record ID, and it is 10 characters, you do not want to pass it to a program that has the record ID defined as 8 characters.

You also want to have the valid values of fields defined consistently, and to be easily visible to the programmer. For instance, if you have a status code, how does the programmer know what each of the code values stand for?

And perhaps most importantly, how do you ensure that if the length or valid values of a field change, all the tables and programs that use them also change?

Magic xpa makes this easy, using models. If a piece of data is attached to a model, that model can define the field length and valid values of that data. Not only that, the model can determine the actual DBMS storage format, encapsulated selection programs, help screens, prompts, tooltips, and more. The settings are easily accessed by the programmer, so they help document the data type.

The model settings are also easily changed, so if you need to add a new status code, changing the status code model will automatically change all the status codes in tables and programs. What's more, you can also find all those status codes by using the (Ctrl+F) facility to make sure your change won’t cause a problem for the logic.

Models that define data are created with the class of field. They are easy to create and even easier to use.

Creating a field model

  1. Go to the Model repository (Shift+F1), and move to the desired location.

  2. Press F4 (Edit->Create Line).

  3. Type in the name of the model (here it is “Status Code”).

  4. Select the class of Field.

  5. Select the attribute you need. For a field model, this would be one of your basic data types: Alpha, Numeric, Date, Time, BLOB, etc.

  6. Now go to the Model Properties pane (Alt+Enter) and set the properties you need. There are a lot of choices here. You can read more about them in the Magic xpa Help.

Details: In this section, you can specify the length and format of the field in its picture. You can also specify the valid values of the field, either as a range (i.e. A-Z) or as discrete values. Here we have a 1-character uppercase field, with 4 possible values.

Input: You can specify a program that will appear when the user presses F5 or double-clicks (zoom), to aid in selecting a value.

Appearance: Here you can attach a help screen, tooltip, or prompt to show on the prompt line.

Style: This section specifies how the data will appear depending on where it is displayed. In this case, our status code will appear as a radio button on most GUI display screens, but will show up as a combo box if it is on a GUI table.

Def/Null: Determines how nulls are used, and if the field has a default value.

Storage/SQL: Here you can specify how the data will be stored in the DBMS.

As you can see, the field models give you a lot of control over how data will be formatted and used in your application. Once the field model is created, you can use it for any instance of this type of data. In this case, we would use it for the status code as it exists in records, as it is passed as a parameter, and in temporary variables in programs.

See also

Reference
Attachment 
Attachment