Popup a new entity form with default values via JavaScript

One of the most useful features I have found recently was being able to use the Xrm object to create window popups for new entities.  I was still using the old way of creating a URL with all the correct parameters, but I didn’t realise that the Xrm.Utilities object now has some very handy functions to allow you to do this.  You can even set up some default properties so that some of the fields are already populated.

function CreateIncident() {    
   //get Account GUID and Name    
   var AccountGUID = Xrm.Page.data.entity.getId();    
   var AccountName = Xrm.Page.data.entity.attributes.get("name").getValue();    
   //define default values for new Incident record    
   var parameters = {};    
   parameters["title"] = "New customer support request";    
   parameters["casetypecode"] = "3";    
   parameters["customerid"] = AccountGUID;    
   parameters["customeridname"] = AccountName;    
   parameters["customeridtype"] = "account";    
   //pop incident form with default values    
   Xrm.Utility.openEntityForm("incident", null, parameters);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.