Skip to main content

Notifications

Announcements

No record found.

Customer Service forum

Mapping Fields does not work if the record is not saved

Posted on by 45

I would appreciate any help.!

The problem is that I have to save the record each time to do "mapping fields" works, so "save the record" and create a new contact  takes too much time to the user who is going to create thousands of records in a moment.

What alternatives I have to improve the user experience.

6254.PNG

85300.png

0878.png

Thanks!

Categories:
  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Mapping Fields does not work if the record is not saved

    Hi,

    As mentioned before, the script suggested above is unsupported and may not work in future. The unified interface has different rendering engine which is why the its not working when we are searching by window.top.Frames[0]...

    I tried other alternatives but none of them are working in UI :(

  • neryhumberto Profile Picture
    neryhumberto 45 on at
    RE: Mapping Fields does not work if the record is not saved

    I Ravi, how you been?

    This is the code that I need to update to UI, would you like to help?

    function loadParentDetails2() {
    
       try {
    
           // Load Account from Parent to Child record
    
           var parentAccount = window.top.frames[0].Xrm.Page.getAttribute("new_cuenta").getValue();
    
           Xrm.Page.getAttribute("parentcustomerid").setValue(parentAccount);
    
       }
    
       catch (err) {
    
           console.log(err.message);
    
       }
    
    }

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Mapping Fields does not work if the record is not saved

    I have updated my first response amd corrected the code.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Mapping Fields does not work if the record is not saved

    The error is becuase I have syntax error in the script... it should be console.log instead of Console.log (small "c").

    Change that and you will not see the error any more however the values will also be not set if you openes it from other entity. This is because the first line checks for the field from your parent account entity

    Hope this helps.

  • neryhumberto Profile Picture
    neryhumberto 45 on at
    RE: Mapping Fields does not work if the record is not saved

    Hi Ravi,

    The Script works fine with the primary entity but when I create a new contact from other entity shows this error.

    ReferenceError: Console is not defined at loadParentDetails (sandboxag.crm.dynamics.com/.../new_CuentaAContacto

  • neryhumberto Profile Picture
    neryhumberto 45 on at
    RE: Mapping Fields does not work if the record is not saved

    Hi Ravi,

    The Script works fine with the primary entity but when I create a new contact from other entity shows this error.

    ReferenceError: Console is not defined at loadParentDetails (sandboxag.crm.dynamics.com/.../new_CuentaAContacto

  • neryhumberto Profile Picture
    neryhumberto 45 on at
    RE: Mapping Fields does not work if the record is not saved

    You are a Saint!. Thank you so much.

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Mapping Fields does not work if the record is not saved

    Hi,

    As you have already noticed that the out of box mapping will only work when the record is saved. This makes sense cause the parent is not saved hence there is no record to pull the data from in database.

    Unfortunately there is no supported way to pass the data from parent to child without saving. I tried some unsupported javascript and it seems to be working fine. You can try and see if it works for you. However it is recommended to not use any unsupported code as it *will* break in future.

    You need to register this method on load. You also need to replace the field schema values.

    =================

    function loadParentDetails() {

       try {

           // Load Account from Parent to Child record

           var parentAccount = window.top.frames[0].Xrm.Page.getAttribute("parentaccountid").getValue();

           Xrm.Page.getAttribute("parentcustomerid").setValue(parentAccount);

       }

       catch (err) {

           console.log(err.message);

       }

    }

    =====================

    Alternatively you could redesign your implementation pass the form data as parameters to form. With this you need to create a separate ribbon button and call the Xrm.Navigation.openForm function to open the child record and pass the data as form parameters.

    docs.microsoft.com/.../set-field-values-using-parameters-passed-form

    You can refer these thread on this:

    community.dynamics.com/.../how-to-pass-parameters-using-openentityform

    community.dynamics.com/.../mapping-parameters-when-opening-a-new-form

    Hope this helps.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans