Forum Discussion

Ginger_Main's avatar
Ginger_Main
New Contributor II
10 months ago

Unable to use UserID in .GetUser api

Update: Found out the user ID is actually supposed to be a Guid object and not a string.    I have a data table which contains a list of UserId's. Currently, I need to convert those UserId's into...
  • keknapp's avatar
    10 months ago

    Not sure this will help you, but I threw this together for an example of how you might be able to retrieve the user names given a list (or in your case a data table) of user id's.  Please note that if your user id's are all strings then you can simply use the "Guid.Parse" method to convert them accordingly.

    'Create list of user id Guid's for example
    Dim userGuid As List(Of String) = New List(Of String)()
    userGuid.Add("73f6f9a1-0ef2-4d00-ba24-d9d8eb978992")
    userGuid.Add("6f373de4-c9bf-4ec3-8b67-5c11f20b5b5e")
    'Loop through the previously created userGuid list
    For Each userId In userGuid
    	Dim userInfo = BRApi.Security.Admin.GetUser(si, Guid.Parse((userId)))
    	'Note, you need to access the user information by referencing the following ->  userInfo.User.
    	'As can be seen in the following line, we can return just the name by retrieving 'userInfo.User.Name'
    	If userInfo IsNot Nothing Then
    		'Write message to error log showing User Name
    		BRApi.ErrorLog.LogMessage(si, userInfo.User.Name.ToString())
    	End If
    Next