SetHookSeesAllRecords

Description

Specifies whether the current hook sees all records or only the records that the current user is allowed to see.

Allows schema developers to control hook visibility for records on a hook by hook basis. The Set function specifies the visibility for the duration of the currently executing hook only.

Setting the method to True (1) specifies that the current hook sees all records when it executes a query. False (0) means the current hook only sees records the current user is allowed to see (based on the actual user privilege of the user for the session) when it executes a query.

For example, if the default behavior is for a hook to not see all records then the following line
  • has no impact
    $session->SetHookSeesAllRecords(0);
  • ensures that the hook sees all records
    $session->SetHookSeesAllRecords(1);

The HOOKS_SEE_ALL_USERS and HOOKS_SEE_ALL_RECORDS master database properties allow schema developers to configure the default visibility for all hooks in their database. For Feature Levels 5 and 6, the default value for these properties is True (1). For Feature Level 7 the default values are False (0). See the command reference for information on CLI commands.

Note: This method became available in version 7.1.

Syntax

VBScript


user_restr = session.SetHookSeesAllRecords set_vis 

Perl


session->SetHookSeesAllRecords(set_vis); 
Identifier
Description
session
The Session object that represents the current database-access session.
set_vis
A Boolean that specifies whether the current hook sees all records or only the records that the current user is allowed to see. True specifies that the current hook sees all records when it executes a record query. False specifies that the current hook can only see records the current user is allowed to see when it executes a record query.
Return value
None.

Examples

VBScript

sub project_ChoiceList(fieldname, choices)
  ' fieldname As String
  ' choices As Object
  ' record type name is Defect
  ' field name is project

set session = GetSession
dim curHookSeesAllRecords

' Store current session "Context"
curHookSeesAllRecords = session.GetHookSeesAllRecords()

' set session context to "User Context"
session.SetHookSeesAllRecords(0)

set querydef = session.BuildQuery("project") 
querydef.BuildField("name") 
set resultset = session.BuildResultSet(querydef)
resultset.Execute 

status =resultset.MoveNext
Do While status = AD_SUCCESS 
   choices.AddItem resultSetObj.GetColumnValue(1) 
Loop 

' revert to original session "Context"
session.SetHookSeesAllRecords( curHookSeesAllRecords )

End Sub

Perl

sub project_ChoiceList 
{
    my($fieldname) = @_;
    my @choices;
    # $fieldname as string scalar
    # @choices as string array
    # record type name is Defect
    # field name is Project

    my $session = $entity->GetSession();
    my ($curHookSessAllRecords);

# store current "Context"
    $curHookSessAllRecords=$session->GetHookSeesAllRecords();

# set to "User Context"
    $session->SetHookSeesAllRecords(0);

    my ($queryDefObj, $resultSetObj);

    $queryDefObj = $session->BuildQuery("Project");

    # have the query return the desired
    # field of the user object(s)
    $queryDefObj->BuildField("Name");
    $resultSetObj = $session->BuildResultSet($queryDefObj);

    # run it
    $resultSetObj->Execute();

    # add each value in the returned column to the choicelist
    while
     ($resultSetObj->MoveNext() == $CQPerlExt::CQ_SUCCESS) {
         push(@choices,$resultSetObj->GetColumnValue(1));
    }

# revert to original session "Context"
    $session->SetHookSeesAllRecords($curHookSessAllRecords);

    return @choices;
}