Skip to main content
Version: v6.5.0

Obtain department information

Command Description

Retrieve department information from enterprise WeChat and return it in array format

Command Prototype

DepartmentArray = WxWork.GetDepartmentList(wxwork_obj, parent_id, recursive)

Command parameter

parametermandatorytypedefault valueInstructions
wxwork_objTrueexpressionWxWorkObjectEnterprise WeChat object created using the WxWork. Create command
parent_idTruestring""Specify a department ID to obtain information about the subordinate departments of this department. If specified as empty or an empty string, retrieve department information for the entire enterprise
recursiveTruebooleanTrueSpecify whether to include all subordinate departments. If not, only obtain the next level department; If yes, the subordinate departments of the subordinate departments will also be obtained until there are no subordinate departments left

Return result

Return_array, Assign the result of running the command to this variable.

Run instance

/********************************* Get Department Information **************************************
Command Prototype:
DepartmentArray = WxWork.GetDepartmentList(wxwork_obj, parent_id, recursive)
Input Parameters:
wxwork_obj -- WeChat Work object. Note: WeChat Work object created using the WxWork.Create command.
parent_id -- Parent department. Note: Specify a department ID to get the subordinate department information of this department. If specified as empty or empty string, retrieves department information for the entire enterprise.
recursive -- Include all subordinate departments (including sub-subordinate departments). Note: Specifies whether to include all subordinate departments. If no, only retrieves the next level of departments; if yes, also retrieves subordinate departments of subordinate departments, until no more subordinate departments exist.
Output Parameters:
return_array -- Variable to store the output of the function call.
Important Notes:
None
********************************************************************************/
Dim return_array = ""
DepartmentArray = WxWork.GetDepartmentList(WxWorkObject, "", True)
TracePrint(return_array)