Documentation Center

Declaring a new metadata field linked with a new LOV

XML setup structures can be designed for adding fields, List of Values (LOV) or LOV values in the Content Manager database. This example focuses on the creation of a new field, creation of a new LOV, and the linking of those two.

About this task

Be sure to follow the naming convention.

Before you link a new LOV to a field, you need to declare the new LOV by defining it in the structure.

For any object (LOV, LOV values or fields) creation, all attributes must be provided.

Procedure

  1. Create the LOV if it doesn't exist yet.
    <lov element="DCOLORSCHEME" issystem="false" ispublic="true">
      <label>Color Scheme</label>
      <description>Describes the color scheme used when publishing.</description>
    </lov>
    
  2. Add the values to the LOV. The attribute isactive should be true.
    <lovvalue element="VCOLORSCHEMECOLOR" isactive="true">
      <label>Color</label>
      <description>Publish in color</description>
    </lovvalue>
    
  3. Create the field. In this example the attribute ismandatory is true, meaning that the field will require a value.
    <field element="FCOLORSCHEME" issystem="false" isbasic="true" ismandatory="true" isindexable="false">
      <label>Color Scheme</label>
      <description>Is used to store a boolean value on the CTOUTPUTFORMAT card type.</description>
      <typelov element="DCOLORSCHEME" ismultivalue="false" />
    </field>
    
  4. Link the field with the card type and add a default value element. The default value is a consequence of the fact that the field's ismandatory is true.
    <cardtype element="CTOUTPUTFORMAT">
      <fielddefinition>
        <cardtypefield element="FCOLORSCHEME">
          <lovfield>
            <defaultvalue ishvaluetype='element'>VCOLORSCHEMECOLOR</defaultvalue>
          </lovfield>
        </cardtypefield>
      </fielddefinition>
    </cardtype>
    
  5. The complete structure would look like this:
    <?xml version="1.0" encoding="utf-8"?>
    <setup version="2.0">
      <lovs>
        <lov element="DCOLORSCHEME" issystem="false" ispublic="true">
          <label>Color Scheme</label>
          <description>Describes the color scheme used when publishing.</description>
          <lovvalues>
            <lovvalue element="VCOLORSCHEMECOLOR" isactive="true">
              <label>Color</label>
              <description>Publish in color</description>
            </lovvalue>
            <lovvalue element="VCOLORSCHEMEBLACKWHITE" isactive="true">
              <label>Black and White</label>
              <description>Publish in black and white</description>
            </lovvalue>
          </lovvalues>
        </lov>
      </lovs>
      <fields>
        <field element="FCOLORSCHEME" issystem="false" isbasic="true" ismandatory="true" isindexable="false">
          <label>Color Scheme</label>
          <description>Is used to store a boolean value on the CTOUTPUTFORMAT card type.</description>
          <typelov element="DCOLORSCHEME" ismultivalue="false" />
        </field>
      </fields>
      <cardtypes>
        <cardtype element="CTOUTPUTFORMAT">
          <fielddefinition>
            <cardtypefield element="FCOLORSCHEME">
              <lovfield>
                <defaultvalue ishvaluetype='element'>VCOLORSCHEMECOLOR</defaultvalue>
              </lovfield>
            </cardtypefield>
          </fielddefinition>
        </cardtype>
      </cardtypes>
    </setup>