ExecuteRolePeopleCode function

Syntax

ExecuteRolePeopleCode(RoleName)

Description

Use the ExecuteRolePeopleCode function to execute the PeopleCode Rule for the Role RoleName. This function returns an array of string containing dynamic members (UserIds).

Typically, this function is used by an Application Engine process that runs periodically and executes the role rules for different roles. It could then write the results of the rules (a list of users) into the security tables, effectively placing users in certain roles based on the rule.

Parameters

Parameter Description

RoleName

Specify the name of an existing role.

Returns

An array of string containing the appropriate UserIds.

Example

The following saves valid users to a temporary table:

Local array of string &pcode_array_users; 
SQLExec("delete from ps_dynrole_tmp where ROLENAME=:1", &ROLENAME); 
   If &pcode_rule_status = "Y" Then 
      SQLExec("select RECNAME, FIELDNAME, PC_EVENT_TYPE, PC_FUNCTION_NAME from
      PSROLEDEFN where ROLENAME= :1", &ROLENAME, &rec, &fld, &pce, &pcf); 
      If (&rec <> "" And 
            &fld <> "" And 
            &pce <> "" And 
            &pcf <> "") Then 
         &pcode_array_users = ExecuteRolePeopleCode(&ROLENAME); 
         &pcode_results = True; 
      Else 
         &pcode_results = False; 
      End-If; 
      &comb_array_users = &pcode_array_users; 
   End-If;