How to Retrieve First name and Last name of Manager?


#1

Hi,

Is there any way to retrieve both the first and last name of a user’s manager as a Data IN value for a field? The only relevant Macro is “Current user.Manager”, which retrieves the USERNAME of the manager. But I need the actual first and last name of the manager instead. Any ideas?

Thanks for reading!


#2

Hi,

Unfortunately, there is not a macro or a built-in feature that allows you to do that.
You can, however, store the full name of the manager in of the extended attributes and use this macro instead.
Otherwise, you can use the Current user.Manager macro to retrieve the username and then query the database in code-behind to retrieve the full name.

Best Regards,
Eddy.


#3

Hi Eddy,
Do you have example code for how to query the WorkflowGen user data.
In my case, I have a username, and I want to Lookup that users First and Last name?
Ideally, it would check to see if they are a user in WorkflowGen at the same time.

Regards
David


#4

Hi David,

You can use the following code as an example :

    string lastname;
    string firstname;
    string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MainDbSource"].ToString();
  string queryString = "SELECT [LASTNAME],[FIRSTNAME] FROM [USERS] WHERE USERNAME = '" + USERNAME + "'";
  
  using(System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(connectionString))
  {
      System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(queryString, sqlConnection);
      sqlConnection.Open();
        using (System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader())
        {
            while (reader.Read()){
                lastname = reader.GetString(0);
                firstname = reader.GetString(0);
            }
        }
  }

#5

Thanks qpomarel,

Works perfectly!