GetLegalActionDefNames

Description

Returns a list of accessible actions for a given record (Entity object).

This method is similar to the GetActionDefNames method of EntityDef; however, the list returned by this method contains only those actions that can be performed on the Entity object in its current state. You can use this method before calling the EditEntity method of the Session object to determine which actions you can legally perform on the record.

In addition to listing only the actions that are allowed based on state, the returned list is also limited to the actions a user has permission to perform. However, this permission check is based only on group access permissions. If instead, the action or any base action has an access_control hook, that hook is not executed to determine if the user has permission to perform the action. Therefore, the user may get a "permission denied" error message when they execute one of those actions.

If this method is called from within a hook, then the user will always have permission to execute any action that is legal for the current state of the record.

Syntax

Perl


$entity->GetLegalActionDefNames(); 
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.
Return value
A reference to an array of strings is returned.

Example

Perl


$sessionobj = $entity->GetSession();



$entitydefname = $entity->GetEntityDefName();



$entitydefobj = $sessionobj->GetEntityDef($entitydefname);



# Search for a legal action with which to modify the record 

$actiondeflist = $entity->GetLegalActionDefNames();



foreach $actionname(@$actiondeflist)
   {
 $actiondeftype = $entitydefobj->GetActionDefType($actionname);

 if ($actiondeftype eq $CQPerlExt::CQ_MODIFY)

  {

  $sessionobj->EditEntity($entity,$actionname);

  }

 }