Trigger for Contact Management update after submitting data via BizForm API

David Pearson asked on August 3, 2016 15:41

I created a custom form control ascx that calls a class that updates the Form module via the BizForm API. This form is outside of Kentico but updates the form in the form module via API call.

Is there a trigger or API call that I need to call to get the Contact management to pick up the data (first name, last name etc) to populate data?

I have the Contact Mapping fill out for this Form in the Form module.
My Contact Us form works good mapping to the contact management, this form is 100% within Kentico nothing fancy.

Kentico 8.2

Thanks David

Correct Answer

Laura Frese answered on August 3, 2016 18:31

Did you check out the API for managing contacts

And if you are interested, managing contact activities

  // Creates a new contact object for the current site
ContactInfo newContact = new ContactInfo()
{
    ContactLastName = "Smith",
    ContactFirstName = "John",
    ContactSiteID = SiteContext.CurrentSiteID,
    ContactIsAnonymous = true
};

// Saves the contact to the database
ContactInfoProvider.SetContactInfo(newContact);
0 votesVote for this answer Unmark Correct answer

Recent Answers


Chetan Sharma answered on August 3, 2016 19:52

Hi David,

If calling an API to create a record is firing Biz form global events, which it should technically, read here https://docs.kentico.com/plugins/servlet/mobile#content/view/21299401

Then On bizform item insert event you can then call contacts create API

https://docs.kentico.com/plugins/servlet/mobile#Contacts-Creatingacontact

This should logically help you accomplish what you want.

Let me know if you are stuck anywhere.

Cheers Chetan

0 votesVote for this answer Mark as a Correct answer

David Pearson answered on August 3, 2016 20:39

I got the BizFormItem.Insert() working: a record is inserted in the form table.

Should that insert call trigger something to update anonymous visitor contact record with the form data that is contact mapped in the form module?

Does the anonymous record get updated with the First Name, Last Name or should a new contact record be created?

Does the SiteContext.CurrentUser.?? have a value to find the anonymous record to update?

Trying to understand how Kentico connects/associates the contact us form to the anonymous visitor record in the Contact Management since it is not IP address base.

0 votesVote for this answer Mark as a Correct answer

David Pearson answered on August 3, 2016 21:34

I think I found the info for Anonymous contact update:

var currentContact = OnlineMarketingContext.CurrentContact;

currentContact.ContactFirstName = record.FirstName;

.....etc etc...

currentContact.Update();

Testing the api call now.

0 votesVote for this answer Mark as a Correct answer

David Pearson answered on August 3, 2016 21:55

Just confirm var currentContact = OnlineMarketingContext.CurrentContact; with currentContact.Update works. This updated the Anonymous record in the Contact Management. Thanks

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on August 4, 2016 14:53

Thanks David for sharing your insights too. I hope my suggestions did help you in tiny way :)

Regards Chetan

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.