function openModalFormOnLoad(executionContext) {
var formContext = executionContext.getFormContext();
var entityName = "gan_casedata";
var formType = 2; // Use the quick create form
// Check if the form is in create mode (new record)
if (formContext.ui.getFormType() === 1) {
var navigateOptions = {
pageType: "entityrecord",
entityName: entityName,
formType: formType
};
var modalOptions = {
target: 2,
position: 1,
width: {
value: 50,
unit: "%"
}
};
Xrm.Navigation.navigateTo(navigateOptions, modalOptions).then(
function (success) {
console.log("Modal form opened successfully.");
// Optionally, you can refresh the current form after closing the modal
// formContext.data.refresh();
},
function (error) {
console.error("Error opening modal form:", error);
}
);
}
}
I'm using the above code to open the modal form for record creation instead of redirecting to the form. The modal form is opening but in a loop it is continuously opening. I added the web resource on the form OnLoad Event. Where did I made a mistake?
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional