Opening a pre-populated child record form in Dynamics CRM

By | April 30, 2014

In a 1:N relationship, when you add a new child record from within a parent form, it will open up the child form with data pre-populated from parent entity based on mapping provided in 1:N relationship.

If you want to add a custom button to replicate the same behaviour, we can use the following code:

var parameters = {};
var childEntityName=”contact”;

//Provide parent record guid
parameters[“_CreateFromId”] = “08A03761-0996-E311-BC31-00155D000807”;

//Provide parent record entity type code
parameters[“_CreateFromType”] = “1”;

//provide child entity name and pass parameter to open new record
Xrm.Utility.openEntityForm(childEntityName, null, parameters);

Parameters:

• _CreateFromId: Pass parent entity record’s GUID

• _CreateFromType: Pass parent entity type code

• childEntityName: Child entity name which need to open with mapping field

With this code snippet, you can add a custom button to simulate the + button on the child subgrids.