Deleting multiple CustomerContacts


Does anyone knows where in the api can we delete a CustomerContact?

I don't see anything in CustomerContext.Current, there's no delete function from the CustomerContact object. In the sdk documentation it's seems to only have examples to create or modify but never delete. There must be a way because we can do it from the commerce customer manager but I can't find it anywhere in the documentation.

If it's not in the api, do we have to do it on the SQL tables directly?

Aug 29, 2012 16:13

You can try this code snippet:

SecurityContext.Current.CheckPermissionForCurentUser(BafModuleConfig.GetDeletePermissionName(className), true);

int errorCount = 0;
Mediachase.BusinessFoundation.Data.Business.BusinessManager.Delete(className, key);
catch (Exception)

className is the name of the class, key is the GUID of the EntityObject in question (e.g. CustomerContact)

Edited, Aug 31, 2012 1:35

Hi Richly,

I couldn't get your code above to work, I'm not sure whether I'm missing something in the config file or doing something in correctly. The error i'm getting is "default securityProvider not found"


var user = Membership.GetUser("admin");
var customerId = "BBB75882-45F3-48F2-ACE7-9F79F0FEA3D3";

SecurityContext.Current.CheckUserInGlobalRole(user, AppRoles.AdminRole);

var customerContact = CustomerContact.CreateInstance();
customerContact.PrimaryKeyId = (PrimaryKeyId?)customerId.ToGuid();
customerContact[App.Default.FieldContactId] = customerId;

Mediachase.BusinessFoundation.Data.Business.BusinessManager.Delete("CustomerContact", (PrimaryKeyId) customerContact.PrimaryKeyId);

Sep 28, 2012 9:30
Mediachase.BusinessFoundation.Data.Business.BusinessManager.Delete(CustomerContact.ClassName, (PrimaryKeyId) customerContact.PrimaryKeyId);


Oct 09, 2012 3:00
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.