5

In the following code...

var contactManager = GetContactManager();
var contact = contactManager.LoadContactReadOnly(contactId);
if (contact == null)
{
    Log.Info("MySite.Presentation.Controllers.ExperienceProfileController.GetAdditionalInfo: Contact not found!: " + contactId.ToString(), this);
    throw new ContactNotFoundException();
}

... contact is apparently null because the ContactNotFoundException is being thrown.

The odd thing is that the contact DOES appear to exist. For example, passing a contactId of f5a28b73-f58b-44f2-a011-4d76bb4984c9 (or any other GUID) results in this error being thrown.

But when I execute the following in the MongoDB...

db.getCollection('Contacts').find({"_id" : NUUID("f5a28b73-f58b-44f2-a011-4d76bb4984c9")})

... I get back a valid result, with visits, etc.:

enter image description here

This code worked fine with 8.1 Update 2/xDB 1.0, but does not work with 8.2 Update 2/xDB 2.0.

Does anyone have any ideas why this behavior would be occurring and how to fix it?

3

Without seeing the implementation of GetContactManager, I can't say what is wrong exactly, but it is most likely the way you're creating the contact manager object.

Here's the correct way of creating it:

ContactManager manager = Factory.CreateObject("tracking/contactManager", true) as ContactManager;

Anyway, the easiest way of achieving what you want is using the ContactRepository instead:

var contactRepository = (ContactRepositoryBase)Factory.CreateObject("contactRepository", true);
var contact = contactRepository.LoadContactReadOnly(contactId);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.