4

Sitecore 8.1 U3

I am trying to fetch customer details from BI and pushing them to sitecore by creating customer items with the necessary details. Each of these customers should be enrolled in an engagement plan when we push/create the customer item in sitecore.

Using WCF service on CM server which creates the customer item and using the below code to programatically enroll the contact in engagement plan as there wont be contact in session to use. Took inspiration from https://maigruen.netzkern.de/use-sitecore-analytics-from-wcf-service.aspx

  if (!Tracker.IsActive) { Tracker.StartTracking(); }
 var siteContext = scConfig.Factory.GetSite("dev");
        using(var context = new SiteContextSwitcher(siteContext))
        {
           Tracker.Current.Session.Identify(contact.Identifiers.Identifier);
            var managerInContext = 
           Tracker.Current.Session.CreateAutomationStateManager();
managerInContext.EnrollInEngagementPlan(engagementPlanId, engagementPlanStateId);
       }

I have also tried creating contact using contactRepository and used the below but dint work either.

var manager = AutomationStateManager.Create(contact);
            manager.EnrollInEngagementPlan(engagementPlanId, engagementPlanStateId);

However, I am getting the contact created in xDb but the automation states are not being set for the contact with the engagement plan.

Any thoughts around this would be appreciated.

Thanks Sri

0

Calling manager.SaveChanges(AutomationManager.Provider) after enrolling user to the plan made the automation transitions work as expected.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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