On the work order quotes how do we get it to load "New Work Order Product" via the Quick Create Form. It seems all the system sub grids on the work order want to open stuff in the "Modal Dialog" I believe what's referred to. Problem is we have a custom Save & New Function. The save and new function and Xrm.Navigate I don't think support Modal dialog, so we programmed it to open a quick form instead. Everything works fine but looks odd to start 1 item as a modal dialog then 2nd item as a Quick Form. We like to just have it all Modal or all Quick Form. I guess this solution can kind of go one or two ways. Need help in getting the subgrid to just default to Quick Form, or help adjusting the code, so it opens a Modal Dialog instead. So, any help is appreciated.
const wait = (ms = 0) => new Promise(resolve => { setInterval(resolve, ms) });
async function SaveAndNew_WOProduct() {
Xrm.Page.data.save();
await wait(2000);
var getLookupData = Xrm.Page.data.entity.attributes.get("msdyn_workorder").getValue();
var workOrderID = getLookupData[0].id;
var workOrderName = getLookupData[0].name;
await wait(2000);
OpenNewForm_WOProduct(workOrderID, workOrderName);
Xrm.Page.ui.close();
}
function OpenNewForm_WOProduct(id, name) {
//https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-navigation/openform
var entityFormOptions = {};
entityFormOptions["entityName"] = "msdyn_workorderproduct";
entityFormOptions["useQuickCreateForm"] = true;
// Set default values for the form
var formParameters = {};
// Set lookup column
formParameters["msdyn_workorder"] = id;
formParameters["msdyn_workordername"] = name;
formParameters["msdyn_workordertype"] = "msdyn_workorder";
// End of set lookup column
// Open the form.
Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
function (success) {
console.log(success);
},
function (error) {
console.log(`Error: ${error}`);
});
}