
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
- In the Saleslogix Administrator, open the DB Manager.
- Add a new field to the CONTACT table called LeadId. Make the field type an SLX Standard ID.
- You may also want to index this field.
- Apply your changes.
Add the newly created field to the Entity Model
- In the Saleslogix Application Architect, expand out the Entity Model for the SalesLogix Application Entities.
- Right click on the Contact entity and choose Update properties.
- Towards the bottom of the list, check the include check box on the new LeadId field.
Add code to populate the LeadId field
- In the Saleslogix Application Architect, expand out the Entity Model for the SalesLogix Application Entities.
- Expand out the Lead entity, Business Rules.
- Double click the ConvertLeadToContact rule.
- Click on the Post Execute Steps tab.
- Click Add to add a new C# Code Snippet.
- Edit the new code snippet. Replace the Commented out line with: contact.LeadId = lead.Id.ToString();
- Save the changes to the rule.
Add Code to the After Contact Save
- In the Saleslogix Application Architect, expand out the Entity Model for the SalesLogix Application Entities.
- Expand out the Contact entity, Events.
- Double click on the OnAfterInsert step.
- Click on the Post Execute Steps tab.
- Click Add to add a new C# Code Snippet.
- 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.
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!