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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Concatenate two fields- Look up and date field into a text field

(0) ShareShare
ReportReport
Posted on by 80

Hi,

I have a requirement to Concatenate look up field and date field into a text field.  We are doing this with an out of box work flow

“Name”: . Value must be ‘First Name’ + “ “ + ‘Date of Birth’

First Name: ABC

DOB: 11/11/1981

Name : ABC 11/11/1986 12:00 AM

20602.Capture.PNG

We don't need to display the time in the NAME field. Could anyone tell us how to get rid of time?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: Concatenate two fields- Look up and date field into a text field

    you will need a custom javascript, custom workflow activity or a plugin in order to hide the time (the way depends on your exact requirement)

  • Suggested answer
    Drew Poggemann Profile Picture
    4 on at
    RE: Concatenate two fields- Look up and date field into a text field

    Hi AXCRM1,

    You can set this through a workflow, I verified this and it worked successfully.  I did the following:

    1.  I setup a real time workflow on a test entity

    2.  I fired the workflow on the change of the name field

    3.  Steps

       a.  Step 1 - Update record to set text field to the Name field value and a space

       b.  Step 2 - Updated record to "Append" the createdon date field

    When I changed the name it saved it correctly with the two field concatenated so I assume it would work fine as well with a day of birth type field.

  • Suggested answer
    PS Profile Picture
    23,577 on at
    RE: Concatenate two fields- Look up and date field into a text field

    Hi

    I would suggest you to do the following:

    Step 1: Hide your field called 'Name' on form (the one which you have mentioned in ur post)

    Step 2: Leave your workflow as it is

    Step 3: Create one more field, Text and calculated and call it 'Name 2' or whatever you want (If u want to know more on how to create calculated field, read [View:http://www.encorebusiness.com/blog/dynamics-crm-calculated-fields/:750:50])

    Click on edit, as shown below:

    51850.2.PNG

    Set formula (copy what I have shown below)

    51850.2.PNG

    Save and close, place the field on form and publish customizations

    Now check, you will be able to get rid of time value.

    To know more about trimleft or trimright function read http://www.powerobjects.com/2015/11/06/use-trimleft-or-trimright-in-calculated-fields/ 

  • Drew Poggemann Profile Picture
    4 on at
    RE: Concatenate two fields- Look up and date field into a text field

    Sorry, I misread the question.  Nice reply Prashant!

  • Suggested answer
    Raghu Krishnamurthy Profile Picture
    80 on at
    RE: Concatenate two fields- Look up and date field into a text field

    Thanks!

  • Suggested answer
    Drew Clark Profile Picture
    75 on at
    RE: Concatenate two fields- Look up and date field into a text field

    Try this JavaScript below and checkout my blog post on concatenating in dynamics, It will show you how to add this JavaScript as a web resource and get it up and running! Please let me know if this works!

    www.clarkandali.com/.../concatenate-in-dynamics-365-with-javascript

    //Concatenate Name and formatted DOB into one field

    function ConcatenateName() {

    //Create a variable for First Name, and DOB

    //Name the variables sensibly and set them equal to the field's logical name

    var name = Xrm.Page.getAttribute("new_firstName").getValue();

    var dob = Xrm.Page.getAttribute("new_dob").getValue();

    //Format the date value from CRM to Day/Month/Year

    var day = dob.getDate() + "";

    var month = (dob.getMonth()+1) + "";

    var year = dob.getFullYear() + "";

    if (dob != "" && dob != null) {

       dob += day + "/" + month + "/" + year;

    }

    //Create a variable to contain the concatenated values

    var nameAndDate = "";

    //Create conditional checks for blank or null values

    if (name != "" && name != null) {

    //Add the name value to the nameAndDate variable

    //Add a space afterwards

    nameAndDate += name + " ";

       }

    //Repeat the conditional checks for Date of birth

    if (dob != "" && dob != null) {

    nameAndDate += dob;

       }

    //push the concatenated value into the field on the form

    //replace new_nameAndDate with the logical name from the form

    Xrm.Page.getAttribute("new_nameAndDate").setValue(nameAndDate);

    }

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

Responsible AI policies

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

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans