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 = WxWork.FindUser(wxwork_obj, user_name, parent_id)

Command parameter

parametermandatorytypedefault valueInstructions
wxwork_objTrueexpressionWxWorkObjectEnterprise WeChat object created using the WxWork. 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 an employee to be searched for
parent_idTruestring""Specify a department ID to search for all subordinate departments (including subordinate departments of subordinate departments) within this department. If specified as empty or empty string, 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 = WxWork.FindUser(wxwork_obj, user_name, parent_id)
Input Parameters:
wxwork_obj -- WeChat Work object. Note: WeChat Work object created using the WxWork.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 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 empty or empty string, 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 = WxWork.FindUser(WxWorkObject, "张三", "")
TracePrint(return_array)