Global script example
The following global script verifies that the current user is a member of the specified group. If the user belongs to the group, the hook returns a value of True.
This example provides a general idea of how you might create a global script. For readability, the example does not include error checking. Check the return value of the Validate API to verify that it includes no errors before you commit the record to the database.
VBScript
Function IsInGroup(groupname)
' groupName As String
' IsInGroup As Bool
Set curSession = GetSession
groupList = curSession.GetUserGroups
IsInGroup = False
For Each group in groupList
If group = groupname Then
IsInGroup = True
Exit For
End If
Next
End Function
Perl
sub IsInGroup {
my ($groupName) = @_;
my ($curSession,
$groupList,
$isInGroup,
$group,
);
$curSession = $entity->GetSession();
$groupList = $curSession->GetUserGroups();
$isInGroup = 0;
foreach $group (@$groupList) {
if ($group eq $groupName) {
$isInGroup = 1;
last;
}
}
return $isInGroup;
}