Adding Users via Webservices

1 minute read time.

If you look at the Sage CRM database tables that are exposed in the WSDL file and also in the "custom_tables" meta data table it looks like you should be able to add users. But when working with the API it will become clear that inserting new user records is not like inserting other records.

In fact you can only create Resources using the WebServices API. A resource is a user that may not logon but can have tasks, and meetings etc assigned to them. Specifically you will need to use the addresource() method to add users.

The addresource() method allows you to add new users into the system when importing data from an external data source and when it is not obvious to which CRM user the data should be assigned. The creation of users as resources prevents the nasty situation of where the web service program could run and create new users which then caused the total users in the system to exceed the number of allowed users in the license. This would then prevent any further logons. To recover from that the users would have to be either deleted, disabled or set as resources.

The method usage (in C#) is like this:


private void buttonAddResource_Click(object sender, EventArgs e)
{
aresource mynewresource = new aresource();
mynewresource.firstname = "Unkown";
mynewresource.lastname = "User";
ewarebase[] baseList = new ewarebase[1];
baseList[0] = mynewresource;
addresourceresult myAddResourceResult = CRM.addresource("users", baseList);
//aresourceid myNewResourceID = (aresourceid)myAddResourceResult.records[0];
for (int x = 0; x
//string strMessage = myNewResourceID.firstname;
//strMessage += myNewResourceID.lastname;
//strMessage += myNewResourceID.resourceid.ToString();
//strMessage += myNewResourceID.logon;
//MessageBox.Show(strMessage);
} }