Skip to main content
Version: v6.5.0

Obtain department information

Command Description

Retrieve department information from DingTalk and return it in array format

Command Prototype

DepartmentArray = DingTalk.GetDepartmentList(DingTalk_obj, parent_id, recursive)

Command parameter

parametermandatorytypedefault valueInstructions
DingTalk_objTrueexpressionDingTalkObjectThe DingTalk object created using the DingTalk. Create command
parent_idTruenumberoneSpecify a department ID to obtain information about its subordinate departments; If specified as 1, retrieve departmental 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 = DingTalk.GetDepartmentList(DingTalk_obj, parent_id, recursive)
Input Parameters:
DingTalk_obj -- DingTalk object. Note: DingTalk object created using the DingTalk.Create command.
parent_id -- Parent department. Note: Specify a department ID to get the subordinate department information of this department; if specified as 1, 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 = DingTalk.GetDepartmentList(DingTalkObject, 1, True)
TracePrint(return_array)