Skip to main content
Skip table of contents

Configure Mandatory Fields - SuperWEB2

It is possible to configure certain fields as "mandatory fields" in SuperWEB2. These fields will be automatically added to all new tables.

By default, users will be able to remove these fields from the table, but you can also activate a rule to prevent this (i.e. it will not be possible to create a table that does not include all the mandatory fields).

Step 1 - Activate the Mandatory Fields Rule

The first step is to activate the mandatory fields rule, by editing <tomcat_home>\webapps\webapi\WEB-INF\data\.repository\RulesEngine.xml in a text editor.

  1. Locate the following section:

    XML
        <rules:RulesPipe name="NewTableRules">
            <!-- <rules:rule-name name="MandatoryFieldsRule"/> -->
        </rules:RulesPipe>
  2. Remove the comments from the rule:

    XML
        <rules:RulesPipe name="NewTableRules">
            <rules:rule-name name="MandatoryFieldsRule"/>
        </rules:RulesPipe>
  3. Save your changes to the file.

Step 2 (Optional) - Configure Mandatory Fields to Be Required in Tables

If you want to prevents users from removing the mandatory fields from the table, then you should also make the following change in <tomcat_home>\webapps\webapi\WEB-INF\data\.repository\RulesEngine.xml:

  1. Locate the following section:

    XML
        <rules:RulesPipe name="CDataOnlineEditRules">
            <!-- <rules:rule-name name="OverrideDefaultSummationRule"/>    -->
            <!-- <rules:rule-name name="MandatoryFieldsRule"/> -->
  2. Remove the comments from the MandatoryFieldsRule:

    XML
        <rules:RulesPipe name="CDataOnlineEditRules">
            <!-- <rules:rule-name name="OverrideDefaultSummationRule"/>    -->
            <rules:rule-name name="MandatoryFieldsRule"/>
  3. Save your changes to the file.

Step 3 - Specify the Mandatory Fields

Once you have activated the mandatory field rule(s), you must specify which fields you want to be mandatory, by editing <tomcat_home>\webapps\webapi\WEB-INF\classes\mandatoryfields.json in a text editor.

This file contains a JSON array defining the list of mandatory fields. For example:

JAVA
 [
    {
        "databases": ["people"],
        "mandatoryFields": [
            {
                "axis": "Row",
                "field": "SXV4__PeopleNonMl__People__Occupation_FLD"
            },
            {
                "axis": "Column",
                "field": "SXV4__PeopleNonMl__People__Marital status_FLD"
            },
            {
                "axis": "Column",
                "field": "Gender",
                "factTable": "People"
            }
        ]
    },
    {
        "databases": ["bank"],
        "mandatoryFields": [
            {
                "axis": "Row",
                "field": "Customer Open Calendar Date",
                "factTable": "Customers",
                "valueSet": "C_Cal_Date_2",
                "values": [
                    "1972 Quarter 1",
                    "2001 Quarter 3",
                    "2005 Quarter 4"
                ]
            },
            {
                "axis": "Row",
                "field": "SXV4__Retail_Banking__F_Customer__Area_FLD",
                "valueSet": "SXV4__Retail_Banking__C_Geography_1",
                "values": [
                    "21510",
                    "22005"
                ]
            },        
            {
                "axis": "Subject",
                "field": "Gender",
                "factTable": "Customers",
                "values": ["Female"]
            },
            {
                "axis": "Column",
                "field": "Marital Status",
                "factTable": "Customers"
            }
        ]
    }
]

Each mandatory field definition can have the following parameters:

ParameterDescriptionRequired?
axis

The axis to add the field to:

  • row
  • column
  • subject (this adds the field as a table filter; you must specify exactly one value, using the values parameter)

You can have multiple mandatory fields on a single axis; the fields will be nested based on the order they are specified in the mandatory fields file (the first mandatory field listed in the file will be at the outermost nested level).

Yes
field

The full SXV4 ID of the field.

You can obtain the field ID in SuperADMIN. Use the command cat <database_id> <field_name>. For example:

CODE
> cat people Occupation
[ XTAB Field : 'Occupation' ]
    [ ID : 'SXV4__PeopleNonMl__People__Occupation_FLD' ]
    [ Value Set : 'SXV4__PeopleNonMl__Occupation' ]

In this example, the ID you need is SXV4__PeopleNonMl__People__Occupation_FLD.

In some cases you can also specify the field using its display name, but if you do this you must also specify the fact table the field belongs to, using the factTable parameter. You are recommended to use the ID in all cases if possible.

Yes
valueSet

The value set to add to the table. If not specified, then the top level value set will be used.

You must use the value set ID, which you can obtain from SuperADMIN using the command cat <database_id> <field_name>.

Only for hierarchical fields, where you do not want to use the top level value set.
valuesA list of the field values to add to the table. If you do not specify a list of values then all values for this field or value set will be added.No
factTableThe fact table the field belongs to.Only if using the display names to identify fields.

When you have finished configuring your mandatory fields file, save your changes and restart Tomcat (or the SuperWEB2 service).

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.