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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Populate Quick Create Form with Data from Parent Form using JavaScript

(0) ShareShare
ReportReport
Posted on by

On my Contact form I have a look up to a custom Details Entity. 

When the New option is selected, a Quick Create Form opens up for a user to input additional details about the new contact.  

The Details form has a name field that I would like to populate with the Contact's full name and append "-Details"

Example. If the new contact that is being created has the name John Smith, I would like that name to prepopulate the Quick Create Details form onload  as  "John Smith-Details" in the name field.

What would the javascript code look like to capture the name from the contact form and use in the Quick Create Form?

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    This is what I have so far, but not working.


    function appendContactDetail(){ var contactName = window.parent.frames[0].Xrm.Page.getAttribute("fullname") Xrm.Page.getAttribute("new_name").setValue( currentName + '-ContactDetail'); }



  • Verified answer
    Drew Poggemann Profile Picture
    4 on at

    Hi Malo073,

    What about doing the following so you do not need JavaScript :)

    Approach

    Create the Name field as a Calculated Field and set the value to CONCAT(new_contactid.fullname, "-Details") where the new_contactid is the contact entity that the Details is related to.

    This will automatically set the value to what you are looking for, although it will not be able to be displayed on the "quick create" form but this is probably not an issue if it is truly a field that is set and can not be manually changed.

    Verification

    I set this up in my own environment and it worked perfectly.  I also changed the first name of the contact and verified it displayed the updated value for the field on the Details entity and it did (which is expected since it is a calculated field) :)

    Other Approaches (if you do not follow above)


    Concerns

    If you create a non-calculated field and are setting the name of the child "Details" entity to the Full Name of the contact record with the "-Details" at the end you will need to concern yourself with the possibility that the name of the Contact could change (i.e. marriage / divorce).  This will cause your name on this record to be out of sync with the contact's name.  There are solutions that you can install that will go through and update child records that relate to a parent (as workflow does not natually do this), please let me know if you would like me to provide this...

    Secondary Recommendation if 1st approach does not work

    1.  Setup workflow that will set the value appropriately after you create the record.  You will not see the value filled in on the form initially but as soon as you save it will show up because you could setup as a synchronous workflow.

    2.  You would need to setup the process to handle the change to the contact's name to update the name field on this entity.  Let me know and I can find this solution for you.

    Hope this makes sense and solves your question.  Please mark verified if so. 

    Thanks,

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    I would suggest resolve your issue in 2 steps.

    1. Create a mapping between contact and your custom entity where fullname of contact is mapped with name field of your custom entity field.

    2. Add onload event handler for Quick Create form that will execute following code:

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

    name = (name == null ? "" : name) + "-Details";

    Xrm.Page.getAttribute("new_name").setValue(name);

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 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