10

I am creating custom facet for saving contact information (Like Car Model, Variant, Color, etc) into XDB. I am successfully able to save and retrieve custom facets details with respective Contact. Now I am trying to show that custom facet on Experience Profile. To do the same I have followed below articles:

1) http://zhenyuan.azurewebsites.net/post/displaying-custom-facets-in-contact-profile

2) http://reyrahadian.com/2016/08/28/sitecore-8-extending-experience-profile-part-3-displaying-contact-facet-collection-property/

3) https://community.sitecore.net/technical_blogs/b/getting_to_know_sitecore/posts/using-custom-contact-data-part-1-experience-profile

4) https://jonathanrobbins.co.uk/2016/04/19/extending-sitecore-experience-profile-speak-app/

What I have done to show Custom facet on Experience Profile:

1) Created web API for retrieving the custom facet.

2) Register API in route

3) Created physical folder in application /Sitecore/shell/client/Applications/ExperienceProfile/Contact/CustomTab

4) Created Custom CSS in core DB and associated it with server location CSS(Deployed CSS in root path)

5) I am using Sitecore Rocks extension as well to customize tab.

Issues I am facing:

1) How to create a custom tab in core DB? (I am creating a duplicate of existing Tab then it's showing new custom tab but existing functionality are not working and replaced with new custom tab)

2) How to associate Speak.Js(use Speak.Js to do the same) with custom tab and controller and display custom facet data?

I am implementing its using Speak JS.

1 Answer 1

9

I do this using Experience Profile Express Tab code. It allows you to add a custom tab to the contact in experience profile. Then you just load your facet into it.

You can put anything in the model. In the code below I am pushing 3 different facets into it. What the code does is looks for any model that is inheriting from the class EpExpressViewModel. If it finds it, it adds a tab in experience profile.

Build a model

public class MemberView : EpExpressViewModel
{
    public override string Heading => "My Tab";
    public override string TabLabel => "Membership";
    public override object GetModel(Guid contactId)
    {
        var contact = EPRepository.GetContact(contactId, MembershipFacet.DefaultFacetKey, PersonalInformation.DefaultFacetKey);
        var memberData = contact.GetFacet<MembershipFacet>(MembershipFacet.DefaultFacetKey);
        var personalInfo = contact.GetFacet<PersonalInformation>(PersonalInformation.DefaultFacetKey);

        return new MemberInfoModel
        {
            ContactId = contact.Id.ToString(),
            VisitCount = 4,
            MemberDataIsNull = memberData == null,
            PersonalInfoIsNull = personalInfo == null,
            MemberData = memberData,
            PersonalInfo = personalInfo
        };
    }
    public override string GetFullViewPath(object model)
    {
        return "/views/MembershipXdb/MemberInfo.cshtml";
    }
}

Make a view

In the view /views/MembershipXdb/MemberInfo.cshtml you can add the HTML from a normal speak panel. It's like getting the look of speak with none of the effort.

When it is done, mine looks like this.

enter image description here

6
  • I am trying to do the same with Speak.JS. Is there any idea/article which describes how to do it with Speak.JS. Apr 20, 2019 at 7:42
  • 1
    Here is how I did originally way back. I think it would still work in 9. It is pretty basic. community.sitecore.net/technical_blogs/b/…
    – Chris Auer
    Apr 20, 2019 at 15:35
  • Thanks, Chrics for the suggestion, but unfortunately no success yet. Below issues I am facing: 1) How to create a custom tab in core DB? (We are creating a duplicate of existing Tab then it's showing new custom tab but existing functionality are not working and replaced with new custom tab) 2) How to associate Speak.Js with custom tab and controller and display custom facet data? Apr 23, 2019 at 7:37
  • 1
    We did custom facet tab for Experience profile as you need with SPEAK and Sitecore Rocks for Sitecore 9.0. I hope this article can be helpful for you konabos.com/blog/…. You can also see our example here github.com/Sitecore-Hackathon/2018-Sitecore-Friends/tree/master/…. To associate custom tab with backend code you should add your custom pipeline into <group groupName="ExperienceProfileContactViews"> section.
    – x3mxray
    May 10, 2019 at 12:12
  • Thanks, @x3mxray, Have seen your article. I am working the same as you did, but unfortunately I am not able to get Contact on bases of contactId. I have raised question for the same, could you please guide or help me. sitecore.stackexchange.com/questions/18571/… May 11, 2019 at 10:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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