Skip to main content
added 7 characters in body
Source Link
Cristi Vulturar
  • 2.3k
  • 2
  • 7
  • 28

In this Sitecore 8.2 Contact object is coming from Sitecore.Analystics.TrackingSitecore.Analystics.Tracking but in Sitecore 9.3 do you need to convert Contact to Sitecore.XConnect.ContactSitecore.XConnect.Contact?

This is Sample code of that class. Facet is working fine, just have some doubt:-. In this class also I am getting parameter contact in form on SItecore.Tracking.Analytics.ContactSitecore.Tracking.Analytics.Contact. How can I convert this contact to XConnect.ContactXConnect.Contact for Sitecore 9.3?

In this Sitecore 8.2 Contact object is coming from Sitecore.Analystics.Tracking but in Sitecore 9.3 do you need to convert Contact to Sitecore.XConnect.Contact?

This is Sample code of that class. Facet is working fine, just have some doubt:- In this class also I am getting parameter contact in form on SItecore.Tracking.Analytics.Contact. How can I convert this contact to XConnect.Contact for Sitecore 9.3?

In this Sitecore 8.2 Contact object is coming from Sitecore.Analystics.Tracking but in Sitecore 9.3 do you need to convert Contact to Sitecore.XConnect.Contact?

This is Sample code of that class. Facet is working fine, just have some doubt. In this class also I am getting parameter contact in form on Sitecore.Tracking.Analytics.Contact. How can I convert this contact to XConnect.Contact for Sitecore 9.3?

added 634 characters in body
Source Link
 Contact contact = _contactProvider.GetCurrentContact();

DocLanguageAndRegionPreferences docPreferences;

_contactRepository.SetDocumentLanguageAndRegionPreference(contact, docPreferences);

I have another class to send and receiveusing this Contactcontact to/from add item to facet and then communicating with Xdb in Sitecore 8.2

 public void SaveContactSetDocumentLanguageAndRegionPreference(Contact contact, DocLanguageAndRegionPreferences docPreferences)
    {
        //if Save(contact the== contactnull)
 and release the lock        return;

        IFacetData facet = contact.GetFacet<IFacetData>(FacetData.FacetName);
        
        if (contactdocPreferences.Languages ==!= null && docPreferences.Languages.Any())
        {
    return;        foreach (var language in docPreferences.Languages)
            {
        var options = new ContactSaveOptions(release: true, owner: _leaseOwner var docLanguage = facet.FacetCentralData.Preferences.DocumentLanguageFilters.Create();
        _contactRepository        docLanguage.SaveContact(contact,Language options);= language;
            }
        }
    }

This is Sample code of that class. Facet is working fine, just have some doubt:- In this class also I am getting parameter contact in form on SItecore.Tracking.Analytics.Contact. How can I convert this contact to XConnect.Contact for Sitecore 9.3?

I have another class to send and receive this Contact to/from Xdb in Sitecore 8.2

 public void SaveContact(Contact contact)
    {
        // Save the contact and release the lock.
        if (contact == null)
            return;

        var options = new ContactSaveOptions(release: true, owner: _leaseOwner);
        _contactRepository.SaveContact(contact, options);
    }

This is Sample code of that class. In this class also I am getting parameter contact in form on SItecore.Tracking.Analytics.Contact. How can I convert this contact to XConnect.Contact for Sitecore 9.3?

 Contact contact = _contactProvider.GetCurrentContact();

DocLanguageAndRegionPreferences docPreferences;

_contactRepository.SetDocumentLanguageAndRegionPreference(contact, docPreferences);

I have another class using this contact to add item to facet and then communicating with Xdb in Sitecore 8.2

public void SetDocumentLanguageAndRegionPreference(Contact contact, DocLanguageAndRegionPreferences docPreferences)
    {
        if (contact == null)
            return;

        IFacetData facet = contact.GetFacet<IFacetData>(FacetData.FacetName);
        
        if (docPreferences.Languages != null && docPreferences.Languages.Any())
        {
            foreach (var language in docPreferences.Languages)
            {
                var docLanguage = facet.FacetCentralData.Preferences.DocumentLanguageFilters.Create();
                docLanguage.Language = language;
            }
        }
    }

This is Sample code of that class. Facet is working fine, just have some doubt:- In this class also I am getting parameter contact in form on SItecore.Tracking.Analytics.Contact. How can I convert this contact to XConnect.Contact for Sitecore 9.3?

Source Link

Sitecore.XConnect.Contact vs Sitecore.Analytics.Tracking.Contact

I am upgrading code from Sitecore 8.2 to Sitecore 9.3.

In Sitecore 8.2 we have a code snippet:-

public Contact GetCurrentContact()
    {
        if (Tracker.IsActive && Tracker.Current != null && Tracker.Current.Session != null)
        {
            return Tracker.Current.Session.Contact;
        }

        return null;
    }

    public Contact IdentifyContact(global::Sitecore.Security.Accounts.User user)
    {
        if (user == null)
            return null;

        string contactIdentifier = GetContactIdentifier(user);

        if (string.IsNullOrEmpty(contactIdentifier) || contactIdentifier.Contains("anonymous") || Tracker.Current == null || Tracker.Current.Session == null)
        {
            return null;
        }

        Tracker.Current.Contact.Identifiers.AuthenticationLevel = AuthenticationLevel.PasswordValidated;
        Tracker.Current.Session.Identify(contactIdentifier);

        return Tracker.Current.Contact;
    }

In this Sitecore 8.2 Contact object is coming from Sitecore.Analystics.Tracking but in Sitecore 9.3 do you need to convert Contact to Sitecore.XConnect.Contact?

I have another class to send and receive this Contact to/from Xdb in Sitecore 8.2

 public void SaveContact(Contact contact)
    {
        // Save the contact and release the lock.
        if (contact == null)
            return;

        var options = new ContactSaveOptions(release: true, owner: _leaseOwner);
        _contactRepository.SaveContact(contact, options);
    }

This is Sample code of that class. In this class also I am getting parameter contact in form on SItecore.Tracking.Analytics.Contact. How can I convert this contact to XConnect.Contact for Sitecore 9.3?