Skip to main content
1 of 8
eat-sleep-code
  • 1.7k
  • 11
  • 25

JavaScript example of populating list in experience profile page

I am setting up a custom tab with custom facet data in the Experience Profile. I am successfully returning text values to the screen.

Now, I want to populate data into a list control. Are there any examples of this.

In my AdditionalInfoPanel I have a GenericDataProvider and a ListControl. My list has three columns -- for Sent, ContactType, and Message.

In my facet...

using Sitecore.Analytics.Model.Framework;

namespace MySite.Models.Facets
{

    public interface IAdditionalInfoFacet : IFacet
    {
        string Company { get; set; }
        string RevenueRange { get; set; }
        string Industry { get; set; }
        string SubIndustry { get; set; }
        IElementCollection<IAdditionalInfoCommunicationElement> Communications { get; }
        bool OptIn { get; set; }
    }
}

I have an instance of an element like this:

using Sitecore.Analytics.Model.Framework;
using System;

namespace MySite.Models.Facets
{
    public interface IAdditionalInfoCommunicationElement : IElement
    {
        DateTime Sent { get; set; }
        string ContactType { get; set; }
        string Message { get; set; }
    }
}

I want to loop through all the "IAdditionalInfoCommunicationElement"s for a contact and put them into my list.

How do I go about doing this in the JavaScript?

define(["sitecore", "/-/speak/v1/experienceprofile/DataProviderHelper.js", "/-/speak/v1/experienceprofile/CintelUtl.js"], function (sc, providerHelper, cintelUtil) {
    var app = sc.Definitions.App.extend({
        initialized: function () {
            var localUrl = "/customfields/";

            providerHelper.setupHeaders([
                { urlKey: localUrl }
            ]);

            var url = sc.Contact.baseUrl + localUrl;
            var $that = this;

            providerHelper.initProvider(this.AdditionalInfoDataProvider, "", url, this.AdditionalInfoTabMessageBar);
            providerHelper.getData(this.AdditionalInfoDataProvider,
                $.proxy(function (jsondata) {
                    cintelUtil.setText($that.CompanyValue, jsondata.Company, true);
                    cintelUtil.setText($that.IndustryValue, jsondata.Industry, true);
                    cintelUtil.setText($that.SubIndustryValue, jsondata.SubIndustry, true);
                    cintelUtil.setText($that.RevenueRangeValue, jsondata.RevenueRange, true);
                    cintelUtil.setText($that.OptInValue, jsondata.OptIn, true);
                    cintelUtil.setText($that.IsKnownExecutiveValue, jsondata.IsKnownExecutive, true);
                    cintelUtil.setText($that.IsKnownCustomerValue, jsondata.IsKnownCustomer, true);
                    cintelUtil.setText($that.IsKnownBlogUserValue, jsondata.IsKnownBlogUser, true);
                }));
        }
    });
    return app;
});

I am using Sitecore 8.1 Update 2

eat-sleep-code
  • 1.7k
  • 11
  • 25