Search code examples
dynamics-crmdynamics-crm-2016

How to pass parameters to a form using grid's plus button?


I open a new form using the + button of a grid, how do I pass parameters to the new form I open without using the

Xrm.Utility.openEntityForm

or can I use Xrm.Utility.openEntityForm in that case ?


Solution

  • If you are talking about OOB Add New (+) button, then you have to do one of these options:

    Either customize that button/command to hook your own javascript action and pass the parameter.

    Or hide the OOB button for future backup usage and add a custom button to invoke custom javascript action and pass parameter.

    On both cases, custom javascript action will have a library and a method. In that custom javascript method, you can use Xrm.Utility.openEntityForm and pass with needed parameters.

    Refer this SO thread

    function invokeCustomAddbutton(){
        var parameters = {};
        parameters["formid"] = "b053a39a-041a-4356-acef-ddf00182762b";
        parameters["name"] = "Test";
        parameters["telephone1"] = "(425) 555-1234";
        Xrm.Utility.openEntityForm("account", null, parameters);
    }
    

    You can keep the above method in a js library, and map that in Ribbon command.

    Reference