#1. Introduction - Deprecated dialogs
Do you still know the old dialogs, which have unfortunately been deprecated for years? π€
It was a very good way to guide users through a process. The user could select different values and based on this, different scenarios could be mapped, such as a case creation, which requires different data from the user as input depending on the selection.
Since the function should no longer be used, there must be a new way to replace this function, or even a better one! Something like that exists. π
#2. Target
Our goal is to create a dialog within Model Driven Apps, empowering users to carry out system-controlled processes. By aligning processes with user actions, we make it easier for users to maintain accurate data π―, saving time β±οΈ and delivering valuable results πͺ. This has a tangible impact on departments like marketing or service, as better data enables more targeted and successful marketing campaigns or a better case resolution. π
In this blog article, for the sake of simplicity (please forgive me π), I do not create a process dialog, but therefore replace a dialog that is provided by the Microsoft standard. The talk is of "Close As Won" in the opportunity form.
So many customers have asked me if this dialog can be modified. Yesβ, it's very easy to do, by ticking a box β in the settings βοΈ and editing the quick create form for opportunity close, but honestly, is that nice? π©
#3. Implementation
#3.1 Create a canvas page
First, you need to create a canvas page that will later be shown as a modal.
Like this:
Yeah, I know ... I have only removed the competitor, but trust me (β) customers have many ideas of important data depending on their businessπ‘.
When the page is created, and is more or less beautiful (I hope more π), then you have to add logic to the page.
There are some things to do and I will show them all very quickly π:
Screen - OnVisible
OR
App - OnStart
Set(varRecord, LookUp(Opportunities, Opportunity = GUID(Param("recordId"))))
β‘οΈ This code snippet is used to retrieve the opportunity record
Submit (OK) button β
// Show a loading spinner to indicate that something is happening Set(varLoadingSpinner, true); // Run a flow for further changes based on the input 'YOUR FLOW'.RUN( // pass the arguments you need for your process varRecord.Opportunity, DropdownCanvas_StatusReason.Selected.Value // ... add more :-) ); // Hide the loading spinner Set(varLoadingSpinner, false); // Close the dialog Back();
β‘οΈ This code snippet is used to display a spinner when calling or executing a flow. The flow is not necessary, you could just write the logic in PowerFx, but with flow there are also possibilities e.g. to send data to external systems like an ERP system. π‘
Cancel button β
// Go back and do nothing
Back();
- Remember your canvas page name after saving, you'll find it in your solution. π
#3.2 Create a JavaScript
Now you have to create the JavaScript to call the dialog.
function OpenCloseOpportunityDialog(formContext) {
var pageInput = {
// open a custom canvas page - do not change this
pageType: "custom",
// replace "YOUR_APPNAME" with your app name
name: "YOUR_APPNAME",
entityName: formContext.data.entity.getEntityName(),
recordId: formContext.data.entity.getId()
};
var navigationOptions = {
// open as dialog
target: 2,
// centered
position: 1,
width: {
// change this based on your page width
value: 400,
unit: "px"
},
height: {
// change this based on your page height
value: 560,
unit: "px"
}
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions)
.then(
function () {
// reload, because it could be closed by your process
formContext.data.refresh(true);
}
).catch(
function (error) {
console.log(error.message);
}
);
}
#3.3 Create a custom command button
In order to be able to call the newly created function to open the dialog, you must create a new command button.
If you don't know how this works, please check my blog post about How to populate data into navigateTo() ββ .
And please remember...
β οΈ Don't forget to set "PrimaryControl" as your first parameter!!!
If you don't want the "old" button to be visible, just open the good old Ribbon Workbench and hide it. If you don't know how to use it: click here to get wisdom.
In this case, I was only allowed to display the button when the opportunity was in the "Open" state, so I had to define a visibility expression.
If(Self.Selected.Item.Status = 'Status (Opportunities)'.Open, true, false)
#3.4 Don't forget to add the page to your Model Driven App
I have already wasted a lot of time trying to find the reason why my dialog was not displayed. Each time I had not added the page to the Model Driven App. Be smarter than me and add it immediately.
#3.5 Result
As a result, we have the finished dialog. It wasn't that difficult, was it? π
In conclusion, through this little example, we have demonstrated the capability of the Power Platform to enable the creation of dialogs within Model Driven Apps using simple yet powerful tools. πͺ
Maybe my example is not that useful π©, but the goal was to show that such a thing is possible β . What you do with it, and how you use the instrument, is another story. π
If you have any cool ideas that can be presented through dialogs, please let me know! π
Feedback is absolutely welcome! π«‘