cancel
Showing results for 
Search instead for 
Did you mean: 
rampprakash

#7 How to Use Open Entity Form in Dataverse Environment

There are two type of Forms Available

1. Main Form

2. Quick View Form

 

1. Main Form:

 

Consider you have a Ribbon Button and on Click on Button you want to Open a Main Form. So for that you can write the below JavaScript command to achieve the same

 

 

var parameters = {
};
parameters["cr608_logicalName1"] = Value1ForLogicalName1;
parameters["cr608_logicalName2"] = Value2ForLogicalName2;

Xrm.Utility.openEntityForm("cr608_EntityLogicalName", null, parameters);

 

 

2. Quick View Form:

 

Consider I have an account Entity and I want to Create an Contact Against that Account for that

 

First Retrieve Account Value and store in a Temporary Variable.

 

 

var retrieveAccountValue = null;
var accountId = null;
var account = primaryControl.getAttribute("parentaccountid"); // you can use formContext from Form. From Ribbon you need to pass Primary Control as Parameter
if (account != null) {
  retrieveAccountValue  = account.getValue();
  if (retrieveAccountValue  != null) {
    accountId = accountValue[0].id;
  }
}

 

 

Then Create a Variable to set the Account Values

 

 

var parentAccountForContact = {
  entityType: "account",
  id: accountId
};

 

 

then you can Call the below code to open a Quick Create Form

 

 

// Create a Parameter
var parameters = {};
//Open Quick Create Form
Xrm.Utility.openQuickCreate("contact", parentAccount, parameters).then(function (ValueOutput) { successCallback(ValueOutput); }, function (error) { errorCallback(error);});
	
// Success Call
function successCallback(success) {
  alert("Success");
}
// Error Call
function errorCallback(e) {
  alert("Error: " + e.errorCode + " " + e.message);
}

 

 

That's it 🙂