web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Work Order Force Quick Form on Subgrids

(0) ShareShare
ReportReport
Posted on by 55

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}`);
    });

}

I have the same question (0)
  • Suggested answer
    Amira Beldjilali Profile Picture
    on at
    RE: Work Order Force Quick Form on Subgrids

    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

  • jdaniel1 Profile Picture
    55 on at
    RE: Work Order Force Quick Form on Subgrids

    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
            }
        );
    
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
#ManoVerse Profile Picture

#ManoVerse 101

#2
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 66 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans