Sets the behavior of a field for the duration of the current action.
Use this method to set the field behavior to mandatory, optional, or read-only. After the action has been committed, the behavior of the field reverts to read-only. You must have ClearQuest Administrator privileges to call this method from an external script. Also, you can call this method only if the Entity object is editable. To make an existing Entity object editable, call the EditEntity method of the Session object.
Because a Record_script_alias is not a true entity action, the behavior of this function is undefined when used in a Record_script_alias action.
For integrations between base IBM Rational ClearCase and IBM Rational ClearQuest, you cannot associate a Rational ClearQuest record with a Rational ClearCase checkin if the Rational ClearQuest record includes required (or mandatory) fields that do not have values specified. Users that try to perform this operation receive an exception error. Users must first enter values for the mandatory fields of the Rational ClearQuest record; or the schema can be changed to provide a hook to be run on the Modify action using the SetFieldRequirednessForCurrentAction method to change the requiredness of a field.
VBScript
entity.SetFieldRequirednessForCurrentAction field_name, newValue
Perl
$entity->SetFieldRequirednessForCurrentAction(field_name, newValue);
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); } }