While using Dynamics 365 CRM, have you ever come across a situation where you are re-entering the same data on different locations or forms? If yes, then you are in the right place; let’s get your problem solved. In our blog, we will get you through the detailed process by which you can pass parameters & data from one form to another form using a single button click, with the addition of JavaScript on the ribbon workbench button’s command.

Dynamic 365

Let’s look at a quick example of how you can do so. Follow the steps below:

  1. Open ribbon workbench.
  2. Select the solution that contains the source entity.

Dynamic 365

3. Add a new command of type Actions. Under that, add JavaScript Action.

Dynamic 365

4. Add a JavaScript action and call OpenDestinationEntityForm function, which is available in existing JS web resources

Dynamic 365

5.Now, add the ribbon button and fill in the necessary details. Also, link the command to the button.

Dynamic 365

6. Publish the changes.

Dynamic 365

7.Once done, navigate to the account and click the button to view the alert.

function OpenDestinationEntityForm() {
    debugger;
    try {
        setTimeout(function() {		
			var entityFormOptions = {};
			entityFormOptions["entityName"] = "destinationEntityInternalName";
			var formParameters = {};
			formParameters["field1InternalNameSourceEntity"] = Xrm.Page.getAttribute("field1InternalNameDestinationEntity").getValue();
			formParameters["field2InternalNameSourceEntity"] = Xrm.Page.getAttribute("field2InternalNameDestinationEntity").getValue();
			formParameters["field3InternalNameSourceEntity"] = Xrm.Page.getAttribute("field3InternalNameDestinationEntity").getValue();
				
			Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
			function (success) {
				console.log("Success..");
			},
			function (error) {
				console.log("Error: " + error);
			});
        }, 500);
    } catch (e) {
        Xrm.Utility.alertDialog(functionName + "Error: " + e.message || e.description);
    }
}

Congratulations, you have successfully passed parameters from one form to another form using the ribbon button with customized ribbon workbench.

If you are planning to customize Dynamics CRM or create custom workflows, business rules, plug-ins, ribbon workbench customization, etc., get in touch with our team of experts or add your comments below in case of query.

Posted by Advaiya

    Let's connect to make technology work for you.





    Please tick the options most relevant to your business challenges
    Decision makingBusiness productivityCustomer experienceTechnology-led innovationDigital transformation


    [By using this form you agree with the storage and handling of your data by this website.]