Hi Community,
i just try to concatenate two string fields into third field using plugin. But its not working with below code
if (entity.LogicalName == "new_tetest")
try
{
Entity test = new Entity("new_tetest");
String fname = test.GetAttributeValue<String>("new_firstname");
String lname = test.GetAttributeValue<String>("new_lastname");
string concat = fname + lname;
concat = String.Concat(fname, lname);
test["new_fullname"] = concat;
service.Create(test);
}
catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("invalidException", ex);
}
*This post is locked for comments
Hi Chaitu ,
If you are facing any difficulty with plugin , you can also create calculated field for the full name .
see below post -
Hi Chaitu,
You plugin code looks fine. You need to check if you have registered it correctly and if it is executing or not. You could use throw new InvalidPluginExecutionException("invalidException", ex); on the top to confirm if plugin is executing or not.
By the way, you can achieve the concatenation by simple workflow or a calculated field-
Hope this helps.
Try with this -
if (entity.LogicalName == "new_tetest") { try { Entity test = new Entity("new_tetest"); String fname = string.Empty; String lname = string.Empty; if (entity.Attributes.Contains("new_firstname")) { if (entity.GetAttributeValue<string>("new_firstname") != "" && entity.GetAttributeValue<string>("new_firstname") != null) { fname = entity.GetAttributeValue<string>("new_firstname"); } } if (entity.Attributes.Contains("new_lastname")) { if (entity.GetAttributeValue<string>("new_lastname") != "" && entity.GetAttributeValue<string>("new_lastname") != null) { lname = entity.GetAttributeValue<string>("new_lastname"); } } test["new_fullname"] = fname + " " + lname; service.Create(test); } catch (FaultException<OrganizationServiceFault> ex) { throw new InvalidPluginExecutionException("invalidException", ex); } }
Hi,
> Are you sure your plugin is running, don't see any issue with the code,
> Are you sure you are filling these attributes.
Where are you checking this concatenation ?? it is creating a new record of your entity, are you not able to see any new record created for your entity having this combined value ??
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156