ContactInfo.ContactAddress2 in Kentico 10

David Pearson asked on January 12, 2018 14:41

I was wondering what other people are doing to record that ContactAddress2 since the property disappear with the update to Kentico 10. Is there another location for storing this?

Thanks David

Correct Answer

David Pearson answered on January 12, 2018 18:51

I over complicated the solution.

Best solutions: Add the field to the class in modules To retrieve and set the field treat it like any other custom field. (GetValue or SetValue) AddressLine2.Value = currentContact.GetValue("ContactAddress2", "");

David

0 votesVote for this answer Unmark Correct answer

Recent Answers


David Pearson answered on January 12, 2018 15:36

I think I found a way to reach the objected of adding ContactAddress2 to the ContactInfo Class.
https://docs.kentico.com/k10/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/configuring-contacts/adding-custom-fields-to-contacts

First I added the field custom field to contacts using the link above.

Next I went to set up Initializing modules to run custom code

Initializing Modules https://docs.kentico.com/k10/custom-development/creating-custom-modules/initializing-modules-to-run-custom-code

I was wondering about the Initializing Module class: I attempting to add Address2 to the module.
[assembly: CMS.RegisterModule(typeof(ContactModule))]

Am I am doing this Class correctly?

Here is the ApplicationInit bit:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CMS.ContactManagement;
using CMS.DataEngine;



[assembly: CMS.RegisterModule(typeof(ContactModule))]
/// <summary>
/// Summary description for ExtendContacts
/// </summary>
public class ExtendContacts : ContactInfo
{
    public ExtendContacts()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    private static void ApplicationInit(object sender, EventArgs e)
    {
        var contactDependencies = (List<ObjectDependency>)ContactInfo.TYPEINFO.DependsOn;
        var contactAddress2 = new ObjectDependency("ContactAddress2", ContactInfo.OBJECT_TYPE);

        contactDependencies.Add(contactAddress2);
    }
}
0 votesVote for this answer Mark as a Correct answer

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