GetFieldRequirednessForUser

Description

Returns the user's view of the field behavior instead of how it appears to a hook. The method finds if a field is set to MANDATORY, OPTIONAL, or READONLY for the current user.

A hook cannot determine whether a field is READONLY for the user by calling the GetFieldRequiredness API. From a hook context, any field can be modified, so the GetFieldRequiredness API will never return READONLY to a hook. The GetFieldRequirednessForUser API always returns the user's view of the field behavior, whether it is called from a hook context or not.

Note: Hooks can always modify the contents of a field, regardless of its current behavior setting.

Syntax

Perl


$entity->GetFieldRequirednessForUser(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

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->GetFieldRequirednessForUser($fieldname); 
	if ($fieldreq eq $CQPerlExt::CQ_MANDATORY) 
	{ 
		# Since it is, make it optional 
		$entity->SetFieldRequirednessForCurrentAction($fieldname, 
		$CQPerlExt::CQ_OPTIONAL); 
	} 
}