Tuesday, November 3, 2009

How to get systemuser details in Plugin

Hi,
Here is an example how to get data in plugin code from server.
the example used to get info from systemuser table, but can be for every type of entity.


public static string GetUserFullName(IPluginExecutionContext context) {
try {
ICrmService service = context.CreateCrmService(false);
ColumnSetBase columns = new AllColumns();
systemuser oSystemUser = (systemuser)service.Retrieve("systemuser", context.UserId, columns);
return oSystemUser.fullname;
} catch (Exception ex) {
return ex.Message;
}


Enjoy,
Rami Heleg