Please I am trying to develop the functionality of allowing users to search for contacts when typed in any order, for example the contact 'Martin Luther King' should return same result even when typed as 'Martin King Luther', 'Luther Martin King' etc
So I added two custom fields 'new_fullnameSFM' & 'new_fullnameSMF' to capture full name in Surname/Firstname/Middlename format & Surname/Middlename/Firstname format respectively and activated them as 'Search Columns'
The issue I have now is I created a plugin such that when a user creates a new 'contact' record, it retrieves the Surname, Firstname & middlename & store them accordingly in the right format into the two custom fields but below code does not achieve result
Thanks
protected void ExecutePreContactCreate(LocalPluginContext localContext)
{
if (localContext == null)
{
throw new ArgumentNullException("localContext");
}
// TODO: Implement your custom Plug-in business logic.
IPluginExecutionContext context = localContext.PluginExecutionContext;
IOrganizationService service = localContext.OrganizationService;
ITracingService tracingService = localContext.TracingService;
Entity entity = (Entity)context.InputParameters["Target"];
ColumnSet cols = new ColumnSet(new String[] { "lastname", "firstname", "middlename", "new_fullnamesfm", "new_fullnamesmf" });
var contact = service.Retrieve("contact", entity.Id, cols);
if (contact != null)
{
string lastnameValue = entity.GetAttributeValue<string>("lastname");
string firstnameValue = entity.GetAttributeValue<string>("firstname");
string midddlenameValue = entity.GetAttributeValue<string>("middlename");
entity.Attributes["new_fullnamesfm"] = lastnameValue + " " + firstnameValue + " " + midddlenameValue;
entity.Attributes["new_fullnamesmf"] = lastnameValue + " " + midddlenameValue + " " + firstnameValue;
}
service.Create(entity);
}
*This post is locked for comments
I have the same question (0)