Fixing the Orphaning of Salesfusion Data when Converting Leads to Contacts in Infor CRM (Saleslogix)

We have had a couple of clients recently come to us with the same problem-

When you convert a Lead to a Contact in Saleslogix, all of the related Salesfusion data in the Salesfusion tables (those starting with SF_) gets orphaned and therefore the resulting Contact record looks as if it has had no prior marketing interactions.

This post describes the steps on how I went around to fix this issue.

Create a new Contact field

  1. In the Saleslogix Administrator, open the DB Manager.
  2. Add a new field to the CONTACT table called LeadId.  Make the field type an SLX Standard ID.
  3. You may also want to index this field.
  4. Apply your changes.

 

Add the newly created field to the  Entity Model

  1. In the Saleslogix Application Architect, expand out the Entity Model for  the SalesLogix Application Entities.
  2. Right click on the Contact entity and choose Update properties.
  3. Towards the bottom of the list, check the include check box on the new LeadId field.

 

Add code to populate the LeadId field

  1. In the Saleslogix Application Architect, expand out the Entity Model for  the SalesLogix Application Entities.
  2. Expand out the Lead entity, Business Rules.
  3. Double click the ConvertLeadToContact rule.
  4. Click on the Post Execute Steps tab.
  5. Click Add  to add a new C# Code Snippet.
  6. Edit the new code snippet.  Replace the Commented out line with: contact.LeadId = lead.Id.ToString();
  7. Save the changes to the rule.

 

Add Code to the After Contact Save

  1. In the Saleslogix Application Architect, expand out the Entity Model for  the SalesLogix Application Entities.
  2. Expand out the Contact entity, Events.
  3. Double click on the OnAfterInsert step.
  4. Click on the Post Execute Steps tab.
  5. Click Add  to add a new C# Code Snippet.
  6. Edit the new code snippet. Put the following code in and save.

Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.ISF_WEBACTIVITY> repository =
                Sage.Platform.EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.ISF_WEBACTIVITY>();
            Sage.Platform.Repository.ICriteria criteria = repository.CreateCriteria();
            criteria.Add(repository.EF.Eq(“LEADID”, contact.LeadId));       
            System.Collections.Generic.IList<Sage.Entity.Interfaces.ISF_WEBACTIVITY> acts = criteria.List<Sage.Entity.Interfaces.ISF_WEBACTIVITY>();
            foreach(Sage.Entity.Interfaces.ISF_WEBACTIVITY act in acts)
            {
                act.CONTACTID=contact.Id.ToString();
                act.Save();
            }
           
           
            Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.ICampaignTarget> repository2 =
                Sage.Platform.EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.ICampaignTarget>();
            Sage.Platform.Repository.ICriteria criteria2 = repository2.CreateCriteria();
            criteria2.Add(repository2.EF.Eq(“EntityId”, contact.LeadId));       
            System.Collections.Generic.IList<Sage.Entity.Interfaces.ICampaignTarget> clks = criteria2.List<Sage.Entity.Interfaces.ICampaignTarget>();
            foreach(Sage.Entity.Interfaces.ICampaignTarget clk in clks)
            {
                clk.TargetType = “Contact”;
                clk.EntityId=contact.Id.ToString();               
                clk.Save();
            }
           
            Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.ISf_Dialog> repository3 =
                Sage.Platform.EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.ISf_Dialog>();
            Sage.Platform.Repository.ICriteria criteria3 = repository3.CreateCriteria();
            criteria3.Add(repository3.EF.Eq(“Lead”, contact.LeadId));       
            System.Collections.Generic.IList<Sage.Entity.Interfaces.ISf_Dialog> dis = criteria3.List<Sage.Entity.Interfaces.ISf_Dialog>();
            foreach(Sage.Entity.Interfaces.ISf_Dialog di in dis)                        
            {
                di.Contact1 = contact;
                contact.Sf_Dialogs.Add(di);
                di.Save();
            }
           
           
            Sage.Platform.RepositoryHelper<Sage.Entity.Interfaces.ISf_Event> repository4 =
                Sage.Platform.EntityFactory.GetRepositoryHelper<Sage.Entity.Interfaces.ISf_Event>();
            Sage.Platform.Repository.ICriteria criteria4 = repository4.CreateCriteria();
            criteria4.Add(repository4.EF.Eq(“Lead”, contact.LeadId));       
            System.Collections.Generic.IList<Sage.Entity.Interfaces.ISf_Event> evs = criteria4.List<Sage.Entity.Interfaces.ISf_Event>();
            foreach(Sage.Entity.Interfaces.ISf_Event ev in evs)
            {
                ev.Contact1 = contact;
                contact.Sf_Events.Add(ev);
                ev.Save();
            }

Note that this code assumes the entity property added to the Contact entity is called “LeadId”.  This is case sensitive so be aware of that.

Finally build and re-deploy.

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!