GetFieldRequiredness
Description
Returns the behavior (requiredness) of a field as defined in the schema for a given state. If no state is given, it returns the default behavior (requiredness) for the field. A field can be mandatory, optional, or read-only.
You can use the GetFieldNames method of the Entity object to
obtain a list of valid names for the field_name parameter.
Syntax
Perl
$entitydef->GetFieldRequiredness($field_name, $state_name);
- Identifier
- Description
- entitydef
- An EntityDef object corresponding to a record type in a schema.
- field_name
- A String that identifies a valid field name of an EntityDef (record type).
- state_name
- A String that identifies a valid state name of an EntityDef (record type).
- Return value
- A Long that identifies the behavior of the named field.
Returns one of the following values MANDATORY, OPTIONAL, READ_ONLY
or USE_HOOK. The value corresponds to one of the
Behavior constants.
Example
Perl
# get field requiredness as defined in the schema.
# Assuming we are in a hook
my $entitydefname = $entity->GetEntityDefName();
my $current_state_name = $entity->LookupStateName();
my $entitydef = $session->GetEntityDef($entitydefname);
my $requiredness = $entitydef->GetFieldRequiredness("Myfield", $current_state_name);