Extracting Form Field Parameters from Metadata

You can use the Salesforce B2C Commerce metadata system instead of the explicitly setting values in the XML form definition. If multiple fields refer to the same meta data, they can be managed from one central place. You can extract the following form field parameters from the B2C Commerce metadata system:

Parameter Description
field ID ID from the attribute definition
field type (see the next table) Type from the attribute definition
field label Display name from the attribute definition
field description Description from the attribute definition
field min and max length String settings from the attribute definition
field min and max value Number range from the attribute definition
field regular expression Regular expression for strings from the attribute definition
field mandatory Flag from the attribute definition

Field types can be as follows:

Field type Description
string field Metadata type string, text, html, set of string
int field Metadata type int, set-of-int
number field Metadata type number
boolean field Metadata type boolean
string field with option list Enum-of-string
int field from option list Enum-of-int

If the business object attribute is an enum-of-int or enum-of-string, then the field is handled as a select box and pre-populated with the values defined in the metadata.

If a field is associated with a metadata definition, the binding is automatically set to that attribute.

Using Metadata Extraction Attributes

Use the object-def attribute with the form, formgroup and list elements. The value of object-def must be the name of a system business object, for example, CustomerAddress, or the name of a custom business object prefixed with Custom, for example, Custom.MyObject.

For individual fields, use the attribute-def attribute, which must refer to the name of an attribute in the metadata definition. The attribute can be a common name, for example, name, or it can refer to a custom attribute, for example, custom.myvalue. A field that references an attribute definition must be embedded in a form group (or a form or a list), which is associated with an object type.

Example

In this example, the merchant is extracting customer address information for existing customers.

<form object-def="CustomerAddress">
 <field attribute-def="firstName"/>
 <field attribute-def="lastName" label="forms.orderaddress.003"/>
 <!-- overwrite label --> <field attribute-def="address1" mandatory="false"/>
 <!-- overwrite mandatory flag --> <field attribute-def="address2"/>
</form>