Skip to main content

Notifications

Announcements

No record found.

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

  • meelamri Profile Picture
    meelamri 13,204 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.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee 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.

  • Suggested answer
    meelamri Profile Picture
    meelamri 13,204 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);
            }
        }
    }
    

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans