RE: Prepopulating Data in Form when opening form using Xrm.Navigation.navigateTo
This works
function LaunchMyForm() {
var extraqs = {};
extraqs["new_firstname"] = GetText(_formContext, "firstname");
extraqs["new_lastname"] = GetText(_formContext, "lastname");
extraqs["new_mobilephone"] = GetText(_formContext, "mobilephone");
extraqs["new_city"] = GetText(_formContext, "address1_city");
extraqs["new_homephone"] = GetText(_formContext, "telephone2");
extraqs["new_otherphone"] = GetText(_formContext, "telephone1");
extraqs["new_personalemail"] = GetText(_formContext, "emailaddress2");
extraqs["new_state"] = GetText(_formContext, "address1_city");
extraqs["new_zippostalcode"] = GetText(_formContext, "address1_postalcode");
var pageInput = {
pageType: "entityrecord",
entityName: "new_myform",
createFromEntity: "",
data: extraqs
};
var navigationOptions = {
target: 2, // 2 is for opening the page as a dialog; 1 is inline
height: { value: 80, unit: "%" },
width: { value: 80, unit: "%" },
position: 1 // 1: Center. 2: on the side
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success() { }, //A function to execute on successful navigation to the page when navigating inline and on closing the dialog when navigating to a dialog.
function error() { } //A function to execute when the operation fails.
);
}
where GetTest() ==
function GetText(formContext, attributeName) {
var textValue = "";
try {
var oAttribute = formContext.data.entity.attributes.get(attributeName);
if (oAttribute !== null) {
textValue = oAttribute.getValue();
}
}
catch (err) { /*do nothing*/ }
return textValue === null ? "" : textValue;
}