Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: concatenation of two string fields

    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

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: concatenation of two string fields

    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.

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: concatenation of two string fields

    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
    Mahendar Pal Profile Picture
    45,095 on at
    RE: concatenation of two string fields

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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans