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}`);
});
}
Ah so close! K i modified this around a bit and got it working.
In case anybody wants my final code bit (Fairly the same as yours, but includes Data Input Example):
function OpenNewForm_WOProduct(id, name) { //https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-navigation/navigateto var pageInput = { pageType: "entityrecord", entityName: "msdyn_workorderproduct", data: { //Map Lookup Fields "msdyn_workorder": id, "msdyn_workordername": name, "msdyn_workordertype": "msdyn_workorder" } }; var navigationOptions = { target: 2, height: { value: 80, unit: "%" }, width: { value: 70, unit: "%" }, position: 1 }; Xrm.Navigation.navigateTo(pageInput, navigationOptions).then( function success(result) { console.log("Record created with ID: " result.savedEntityReference[0].id " Name: " result.savedEntityReference[0].name) // Handle dialog closed }, function error() { // Handle errors } ); }
Hello jdaniel1,
Please have a look to this, it should resolve the point : learn.microsoft.com/.../navigateto
There is an example to open an existing record
var pageInput = { pageType: "entityrecord", entityName: "account", entityId: "5a57f2c3-5672-ea11-a812-000d3a339706" //replace with actual ID }; var navigationOptions = { target: 2, height: {value: 80, unit:"%"}, width: {value: 70, unit:"%"}, position: 1 }; Xrm.Navigation.navigateTo(pageInput, navigationOptions).then( function success() { // Run code on success }, function error() { // Handle errors } );
Regards,
Amira
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,524 Super User 2024 Season 2
Martin Dráb 228,493 Most Valuable Professional
nmaenpaa 101,148