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

Notifications

Announcements

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

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans