Wednesday, 27 June 2018

Open and fill new form using JavaScript in Dynamic CRM

Opening a pre-populated child record form in Dynamics CRM

Description:
In this example we explain that how to open and fill new form in Dynamic CRM using JavaScript. Or how to open new form with fill up data in Dynamic CRM using JavaScript and XRM. Or fill relationship data in new form entity using JavaScript in Dynamic CRM. Or set field value using parameters passed to form in Dynamic CRM using JavaScript.

Here we demonstrate that how to populate field on form load using JavaScript in Dynamic 365.so first we open child entity form and fill up the data by passed by parameters using JavaScript in Dynamic CRM.So below is the JavaScript code to set field values using parameters passed to a form in Dynamic CRM.
Code:

function OpenNewContactForm() {
        var parameters = {};
        //Set the Parent Customer field value to "Contoso".
        parameters["parentcustomerid"] = "2878282E-94D6-E111-9B1D-00155D9D700B";
        parameters["parentcustomeridname"] = "Contoso";
        parameters["parentcustomeridtype"] = "account";
        //Set the Address Type to "Primary".
        parameters["address1_addresstypecode"] = "3";
        //Set text in the Description field.
        parameters["description"] = "Default values for this record were set programmatically.";
        //Set Do not allow E-mails to "Do Not Allow".
        parameters["donotemail"] = "1";

        // Open the window.
        Xrm.Utility.openEntityForm("contact", null, parameters);

        //you can also set dynamic data like
        // parameters["parentcustomeridtype"] = Xrm.Page.getAttribute("companyname").getValue();
    }



1 comments:

  1. So the parameter's name should be same as the field name in child entity.?? Or we need to set the data from parameters onLoad of child form..??

    ReplyDelete