Skip to main content
Version: v6.5.0

Search for employees by name

Command Description

Search for employees whose names match exactly. Return employee IDs in array format

Command Prototype

UserIdArray = DingTalk.FindUser(DingTalk_obj, user_name, parent_id)

Command parameter

parametermandatorytypedefault valueInstructions
DingTalk_objTrueexpressionDingTalkObjectThe DingTalk object created using the DingTalk. Create command
user_nameTruestringZhang SanThe complete name of the employee to be searched can be one employee or multiple employees. If there are multiple employees, please use an array to represent them, where each element in the array is the name of the employee to be searched for
parent_idTruenumberoneSpecify a department ID to search for all subordinate departments (including subordinate departments of subordinate departments) within this department; If specified as 1, search for all departments in the entire enterprise

Return result

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

Run instance

/********************************* Find Employee by Name ************************************
Command Prototype:
UserIdArray = DingTalk.FindUser(DingTalk_obj, user_name, parent_id)
Input Parameters:
DingTalk_obj -- DingTalk object. Note: DingTalk object created using the DingTalk.Create command.
user_name -- Employee name. Note: The full name of the employee(s) to search for. Can be a single employee or multiple employees. If multiple employees, represent as an array where each element is an employee name to search for.
parent_id -- Parent department. Note: Specify a department ID to search within all subordinate departments (including sub-subordinate departments) of this department; if specified as 1, searches across all departments in the entire enterprise.
Output Parameters:
return_array -- Variable to store the output of the function call.
Important Notes:
None
********************************************************************************/
Dim return_array = ""
UserIdArray = DingTalk.FindUser(DingTalkObject, "张三", 1)
TracePrint(return_array)