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 365 | Integration, Dataverse...
Suggested Answer

New contact name from lookup

(0) ShareShare
ReportReport
Posted on by 580

Hi,

I would like to know if it is possible to change the mapping of a lookup field when I do a quick create?

Here is my example:

In the case form I type a first name of a contact that does not exist in Responsible contact lookup field.

I now have the option to create a new contact out of this first name.

When I click New contact, it defaults the first name to the last name field in the Quick create form (shown below)

How can I change so that when I click New contact the information goes to First Name instead?

pastedimage1624369499108v1.png

pastedimage1624369574803v2.png

I have the same question (0)
  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at
    RE: New contact name from lookup

    Hi, 

    I don't know if there is a direct way to do this mapping. But I suggest you a workaround that could solve your problem. Indeed, a JS code that is fired at the loading of your quick Create can swap the firstname and lastname values. Please refer to the code below: 

    if (typeof (MEA) == "undefined") { MEA = {} };
    if (typeof (MEA.Contact) == "undefined") { MEA.Contact = {} };
    if (typeof (MEA.Contact.QuickCreateForm) == "undefined") { MEA.Contact.QuickCreateForm = {} };
    
    MEA.Contact.QuickCreateForm = {
        onLoad: function (executionContext) {
            var formContext = executionContext.getFormContext();
            var firstName = formContext.getAttribute('firstname').getValue();
            var lastName = formContext.getAttribute('lastname').getValue();
    
            if(lastName!=null && firstName==null){
                formContext.getAttribute('firstname').setValue(lastName);
                formContext.getAttribute('lastname').setValue(null);
            }
        }
    }
    

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: New contact name from lookup

    Hi Fritz,

    It’s OOB behaviour, the last name field can be populated automatically with value from lookup field.

    But you can create a business rule to populate the first name field with the value.

    1.Go Settings > Customizations > Customize the system > Entities > Contact > Business rules.

    pastedimage1624434127125v2.png

    2.Create new business rule:

    IF

    First Name does not contain data AND Last Name contains data

    THEN
    Set First Name to Last Name
    Clear Last Name

    pastedimage1624434109454v1.png

    3.Then save and active it, publish all customizations.

    4.Test:

    The First name field has been filled automatically and last name is null.

    pastedimage1624434226647v3.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • meelamri Profile Picture
    13,216 User Group Leader on at
    RE: New contact name from lookup

    Hi Leah Ju,

    I think it's a bad idea to use a BR for this kind of scenario. In fact, the Business rule will be applied to all forms because a BR can't be related to QuickCreat form only. Also, the logic will be applied each time the fistName is empty and the lastName is not empty.

    Don't hesitate to correct anything if I'm wrong, thanks.

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…

Neeraj Kumar – Community Spotlight

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

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
#ManoVerse Profile Picture

#ManoVerse 101

#2
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 66 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans