GetFieldRequiredness
Description
Identifies the behavior of the specified field.
A
field can be mandatory, optional, or read-only. If the entity is not
an editable Entity object, this method always returns the value READONLY.
If the Entity object is editable, because an action has been initiated,
the return value can be READONLY
, MANDATORY
,
or OPTIONAL
.
This method never returns the value USE_HOOK. If the behavior of the field is determined by a permission hook, HCL Compass will have already executed that hook and cached the resulting value. This method then returns the cached value.
Note: Hooks
can always modify the contents of a field, regardless of its current
behavior setting. If the field is
READONLY
to a HCL Compass user
but is modifiable in the context of a hook, then the return value
is not READONLY
. See the GetFieldRequiredness of
the EntityDef object to return the defined (READONLY
)
behavior of the fields of a record type.You
can use the GetFieldNames
method
to obtain a list of valid names for the field_name parameter.
Syntax
VBScript
entity.GetFieldRequiredness
(field_name)
Perl
$entity->GetFieldRequiredness
(field_name);
- Identifier
- Description
- entity
- An Entity object representing a user data record. Inside a hook, if you omit this part of the syntax, the Entity object corresponding to the current data record is assumed (VBScript only).
- field_name
- A String that identifies a valid field name of entity.
- Return value
- A Long that identifies the behavior of the named field.
The value corresponds to one of the
Behavior constants
.
Examples
VBScript
' Change all mandatory fields to optional
' Retrieve the collection of fields
fieldNameList = GetFieldNames
For Each fieldName in fieldNameList
' Find out if the selected field is mandatory
fieldReq = GetFieldRequiredness(fieldName)
if fieldReq = AD_MANDATORY
' Since it is, make it optional
Then SetFieldRequirednessForCurrentAction fieldName, AD_OPTIONAL
End If
Next
Perl
# Change all MANDATORY fields to OPTIONAL
# Retrieve the collection of fields
$fieldnamelist = $entity->GetFieldNames();
foreach $fieldname (@$fieldnamelist)
{
# Find out if the selected field is mandatory
$fieldreq = $entity->GetFieldRequiredness($fieldname);
if ($fieldreq eq $CQPerlExt::CQ_MANDATORY)
{
# Since it is, make it optional
$entity->SetFieldRequirednessForCurrentAction($fieldname,
$CQPerlExt::CQ_OPTIONAL);
}
}