Currency/Measure

The Currency/measure client control shows a combination of a value and a unit. For example, the value "5" has no context without the unit "$". When grouping the value and unit into a combination, it also saves space, and ensures that both are shown with one another.

Currency/Measure

Figure 1 - Currency/Measure control with value and unit as one combination.

Currency/Measure

Figure 2 - Currency/Measure control (read-only mode).

Currency/Measure

Figure 3 - Currency/Measure control (edit mode).

Variations

Currency/Measure can be added either as a currency or a measure control. The functionality is the same regardless if it is added to use currency or measure, but it is recommended to only use currency when the unit is a currency, and measure for other value/unit combinations.

When to use

Use a Currency/Measure client control to show a value and unit as one combination. When a value and unit are combined, it is still possible to change each of them individually, or make only one of them editable.

In IFS applications there is also a basic data setup for both Currency Codes and Unit of Measure. When these data setups are applied, it ensures that only valid currencies and unit of measures are used.

Currency/Measure can be placed in groups, lists, selectors and cards.

How to use

The steps below describes how to add a currency/measure client control to a page:

Defining the entity file

  1. Define the two attributes in the .entity file. One attribute for the value, and one for the unit.

attributes {
   ...
   public       EntryFee           NUMBER               A-IU-;
   public       CurrencyCode       TEXT(3)/UPPERCASE    A-IU-;
}

Defining the projection file

  1. If necessary, define the entityset to use a lookup in the .projection file.

entityset IsoCurrencyEntitySet for IsoCurrency;
entityset IsoUnitSet for IsoUnit;

Defining the client file

  1. Define the currency code in the .client file.

currency EntryFee(CurrencyCode) {
   unitlookup IsoCurrencyEntitySet(CurrencyCode);
   unitselector IsoCurrencySelector;
}

selector IsoCurrencySelector for IsoCurrency { static CurrencyCode; }

Setting the appropriate properties to the currency/measure client control

The unit can be set to read-only, which makes it possible to only change the value on the field, but not the currency/measure unit.

NOTE! It is not necessary to define the property unitlookup when the unit is read-only.

  1. Set the property to be not editable in the .projection file or in the .client file.

uniteditable = [false];
currency EntryFee(CurrencyCode) {
   uniteditable = [false];
}

Example code - The property uniteditable is set to false in the client file

  1. Hide the unit, for example if the value is null.

currency EntryFee(CurrencyCode) {
   unitvisible = [EntryFee != null];
   uniteditable = [false];
}

Example code - The property unitvisible is set to hide the unit

  1. Set the unit to only be editable during creation of a record.

uniteditable = [IsNew];

Add Currency/Measure to a container

  1. Add the Currency/Measure control to the same places as for any other field (inside a Group, List, Selector, or Card.

list <list_name> {
    ...
    currency <data_item_name>(CurrencyitemRef) {
        ...
    }
    measure <data_item_name>(MeasureitemRef) {
       ...
    }
}

------ Example code -------
//Adding to a list
list Currlist for AranlkTest {
   &DynamicComponentDependency ACCRUL
   currency Amount(Currency) {
      unitselector CurrSelector;
      unitlookup IsoCurrset(CurrencyCode);
   }
}
//Adding to a group
group NewGroup for AranlkTest {
   &DynamicComponentDependency ACCRUL
   currency Amount(Currency) {
      unitselector CurrSelector;
      unitlookup IsoCurrset(CurrencyCode);
   }
}
//Adding to a card
group NewCard for AranlkTest {
   &DynamicComponentDependency ACCRUL
   currency Amount(Currency) {
      unitselector CurrSelector;
      unitlookup IsoCurrset(CurrencyCode);
   }
}
//Adding to a selector
selector CurrencySelector for AranlkTest {
   orderby = TestKey;
   label = "${TestKey} - ${TestName} ";
   static TestName {
      label = "Currency Name";
   }
   &DynamicComponentDependency ACCRUL
   currency Amount(Currency) {
      unitselector CurrSelector;
      unitlookup IsoCurrset(CurrencyCode);
   }
}

Limitations

None.

Properties

Below is a list of properties that can be used to customize the control.

columnexclude | columnvisible | editable | format | label | preserveprecision | required | searchable | showlabel | size | uniteditable | unitexportlabel | unitlookup | unitrequired | unitselector | unitvisible | validate command | visible

Example

Below is an example of a currency and a measure field.

Currency/Measure

Figure 4 - Currency/measure example (non-expanded)

Currency/Measure

Figure 5 - Currency/measure example (expanded)

------ Example code for currency/measure ------
-------------- Projection file ----------------

entityset IsoCurrencySet for IsoCurrency; entityset IsoUnitSet for IsoUnit;

----------------- Client file -----------------

//Code for Field measure MyMeasureValue(MyMeasureCode) { label = "My Measurement"; unitselector MyIsoUnitSelector; unitlookup IsoUnitSet(UnitCode); required = [true]; unitexportlabel = "Its my Measure Unit"; } currency MyCurrencyValue(MyCurrencyCode) { label = "My Currency"; unitselector MyIsoCurrencySelector; unitlookup IsoCurrencySet(CurrencyCode); unitexportlabel = "Its my Currency Unit"; } //Code for selectors selector MyIsoUnitSelector for IsoUnit { orderby = UnitCode; static UnitCode; } selector MyIsoCurrencySelector for IsoCurrency { orderby = CurrencyCode; static CurrencyCode; }