I use plugins to set names of such entities. To simplify development of such plugins I did a base class and want to share it with you.
Let me show you example of the plugin which is based on SetNamePluginBase (base plugin) I share below.
using ExitoConsulting.Plugins.Base;
using Microsoft.Xrm.Sdk;
namespace ExitoConsulting.Plugins
{
public class OwnerSetName : SetNamePluginBase
{
protected override string GetName(Entity entity, IPluginExecutionContext context, IOrganizationService service)
{
var fullName = entity.GetAttributeValue("ec_fullname");
var clientId = entity.GetAttributeValue("ec_clientid");
if(string.IsNullOrEmpty(fullName))
{
return null;
}
var name = fullName;
if(!string.IsNullOrEmpty(clientId))
{
name = name + string.Format(" - {0}", clientId);
}
return name;
}
}
}