ContentType Field Exists Example

This example first uses the contenttype.field.exists() viper to check if a certain logical field name exists for the specified contenttype, before retrieving the physical fieldname for that field.

Without first checking if a field exists you risk an exception, because the contenttype.field() viper will raise an exception when you specify a non-existing logical fieldname.

Smartsite SXML CopyCode image Copy Code
{sys.iif(contenttype.field.exists(WP,defaultcontenttype),
    contenttype.field("defaultcontenttype", "WP"),
    'field does not exists')}
Example Result CopyCode image Copy Code
CTSpecificInt1