Monday, October 22, 2007

How to Retrieve system user list efficiently

Do you need a list of all users in CRM 3.0?

if so do the following:

Here is the Fetch XML that I used to pull all the system users

<fetch mapping='logical'><entity name='systemuser'><all-attributes/></entity></fetch>

To retrieve the list simply use this C# code:

string result = service.Fetch(fetchxml);


XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(result);

To loop through the list and fill a drop down list for example:

XmlNodeList userList = xdoc.SelectNodes("resultset/result");


foreach(XmlNode n in userList)
{
ListItem itm = new ListItem();
itm.Text = n["fullname"].InnerText;
itm.Value = n["systemuserid"].InnerText;
ddlUserList.Items.Add(itm);
}

It is that simple.

Oshri Cohen

Labels: , , , , , ,

1 Comments:

At March 30, 2008 at 10:33 AM , Anonymous Anonymous said...

Thank you very much!!
It was exactly what i need!!

 

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home