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.
Let’s look at a quick example of how you can do so. Follow the steps below:
- Open ribbon workbench.
- Select the solution that contains the source entity.
3. Add a new command of type Actions. Under that, add JavaScript Action.
4. Add a JavaScript action and call OpenDestinationEntityForm function, which is available in existing JS web resources
5.Now, add the ribbon button and fill in the necessary details. Also, link the command to the button.
6. Publish the changes.
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.