web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

concatenation of two string fields

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    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 ??

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    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);
                                }
                            }

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    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-

    crmramblingsbysteven.wordpress.com/.../microsoft-crm-2015-how-do-i-concatenate-two-fields-in-microsoft-crm-2015-revised

    crmramblingsbysteven.wordpress.com/.../how-to-concatenate-two-fields-using-workflow-in-dynamics-crm-2011

    Hope this helps.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Chaitu ,

    If you are facing any difficulty with plugin , you can also create calculated field  for the full name .

    see below post -

    crmramblingsbysteven.wordpress.com/.../microsoft-crm-2015-how-do-i-concatenate-two-fields-in-microsoft-crm-2015-revised

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans