Documentation

GetList

CDBResult CUserFieldEnum::GetList(
 array aSort = array(),
array aFilter = array()
)

The method returns list values of user field as an CDBResult object class. Sorting by SORT field is default for aSort parameter. Additional sorting is by ascending ID. Non-static method.

Parameters

ParameterDescription
aSortArray for value sorting. The following keys are available in the array:
  • ID - list value ID;
  • USER_FIELD_ID - user field ID;
  • VALUE - printed value;
  • DEF - default flag;
  • SORT - sorting;
  • XML_ID - external source code.
Key values can be the following:
  • ASC - by ascension
  • DESC - be descension
aFilterArray for value filtration. The following keys are available in the array:
  • ID - list value ID;
  • USER_FIELD_ID - user field ID;
  • VALUE - printed value;
  • DEF - default flag;
  • SORT - sorting;
  • XML_ID - external source ID.
Keys values specify a precise match for filtration.

See Also

Examples

<?
//User property is defined for users
// list type with ID of UF_GENDER. Print the value for
// the current user.

//First, get user field value:
global $USER;
if(is_object($USER))
{
$rsUser = CUser::GetList($by, $order,
array(
"ID" => $USER->GetID(),
),
array(
"SELECT" => array(
"UF_GENDER",
),
)
);
if($arUser = $rsUser->Fetch())
{
$rsGender = CUserFieldEnum::GetList(array(), array(
"ID" => $arUser["UF_GENDER"],
));
if($arGender = $rsGender->GetNext())
echo $arGender["VALUE"];
}
}
?>

Example of getting the list by user field ID:

$obEnum = new \CUserFieldEnum;
        $rsEnum = $obEnum->GetList(array(), array("USER_FIELD_ID" => $arUserField["ID"]));

        $enum = array();
        while($arEnum = $rsEnum->Fetch())
        {
            $enum[$arEnum["ID"]] = $arEnum["VALUE"];
        }


© «Bitrix24», 2001-2022
Up