GetLegalAccessibleActionDefNames
Description
Returns a list of accessible actions for a given record (Entity object) that are both legal for the user and possible to execute if there is an access control hook defined.
The list returned by this method contains only those actions that can be performed on the Entity object in its current state by the current user. You can use this method before calling the EditEntity method of the Session object to determine which actions a user 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.
This method is similar to GetLegalActionDefNames, but it also determines whether the user has permission to perform an action by checking each legal action for access control hooks and determining whether or not the user passes the access control. If access control blocks the user then the action is not returned to the user in the list of returned 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
VBScript
entity.GetLegalAccessibleActionDefNames
Perl
$entity->GetLegalAccessibleActionDefNames
();
- 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).
- Return value
- For Visual Basic, a Variant containing an array of strings
is returned. Each String contains the name of a legal action. If no actions
can be performed on the Entity object, the return value is an Empty variant.
For Perl, a reference to an array of strings.
Examples
VBScript
Dim EntityObj As OAdEntity
Set sessionObj = GetSession
Set EntityObj = sessionObj.GetEntity("Defect", "SAMPL00000001")
entityDefName = EntityObj.GetEntityDefName
Set entityDefObj = sessionObj.GetEntityDef(entityDefName)
' Get the legal accessible actions
actionDefList = EntityObj.GetLegalAccessibleActionDefNames
If IsArray(actionDefList) Then
For Each actionDef in actionDefList
msg2 = msg2 & " " & actionDef
Next
End If
MsgBox "Legal accessible actions are: " & msg2
Perl
$sessionobj = $entity->GetSession();
$entitydefname = $entity->GetEntityDefName();
$entitydefobj = $sessionobj->GetEntityDef($entitydefname);
# Search for a legal action with which to modify the record
$actiondeflist = $entity->GetLegalAccessibleActionDefNames();
foreach $actionname(@$actiondeflist)
{
$actiondeftype = $entitydefobj->GetActionDefType($actionname);
if ($actiondeftype eq $CQPerlExt::CQ_MODIFY)
{
$sessionobj->EditEntity($entity,$actionname);
}
}