In my Model-Driven App, I wanted users to be able to use the Quick Create Form when click the New button.
Seemed like a pretty simple request, but like most things, it wasn’t.
I was able to use the Quick Create From from a Sub-grid or a Lookup, but not a View.
What to do?
Enter JavaScript and Xrm ToolBox.
I first created a Solution, which I called How To Use Quick Create Solution
.
I added a Table called Item
and made sure to check Leverage quick-create form if available
, which would allow me to create a Quick Create Form.
I added a couple of rows to the Items
table.
I then created a Model-Driven App which I called, How To Use Quick Create Model-Driven App
.
I know, my naming conventions are super impressive. 😊
In my Model-Driven App I set the current Subarea1 to display my Active Items
in the Items
table.
If I click New on the View command bar, it takes me to the Information
form, which is the Main Form. As I mentioned, I would like this to be the Quick Create Form instead.
Now for the real work.
From Pages, I clicked on the three dots next to Item, and then clicked on Edit command bar.
When presented with Choose a command bar to edit, I choose Main grid
and then clicked Edit.
Next, from the menu, I clicked New and then Command.
When prompted for Which type of command would you like to create? I chose JavaScript
and then clicked Continue.
I new Command was added labeled NewCommand
.
I set the Label property for the command to New
.
I set Icon to User Icon
, and then selected the Add
icon.
Now to add the JavaScript.
I used Visual Studio Code to create a file called HowToUseQuickCreate.js
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
function quickCreate() { var entityFormOptions = {}; entityFormOptions["entityName"] = "maruma_item"; entityFormOptions["useQuickCreateForm"] = true; Xrm.Navigation.openForm(entityFormOptions).then( function (success) { console.log(success); }, function (error) { console.log(error); }); } |
I had to replace the value of entityFormOptions["entityName"]
with the name of my Entity, which I pulled from the Solution, which in my case, was maruma_item
.
From the Properties for my new command, I clicked Add library under Library, and then clicked New web resource.
I then chose my JavaScript file I created, and added a Display Name and Name.
I then clicked Save and publish.
I could now choose my JavaScript library, after which I clicked Add.
I set Function name to quickCreate
, which is the name of my JavaScript function to display the Quick Create Form.
Then I clicked Save and Publish from the main command bar.
I then click Play.
I see two New buttons, when I click the one I created, it takes me to the Information Main Form.
Doh! Well that makes perfect sense, I forgot to create a Quick Create Form!
In another tab, I navigated to my Solution, clicked on Tables, clicked on the Item table and then clicked on Forms.
I then clicked New Form, followed by Quick Create Form.
For the Quick Create Form I did the following:
- Renamed the first Section to
General
- Checked Hide for each of the other two Sections.
- Added the Name field.
I then clicked Save and publish.
Now when I run my Model-Driven App and click the New button I added, the Quick Create Form is displayed.
Note: I did have some trouble getting the Quick Create Form to display right away, the more I work in the Power Platform, the more I realized things just take time. So with a combination of publish and patience, my Quick Create Form was working perfectly.
Now how can I get rid of hide those other New buttons? From what I understand, because these are “classic” buttons, they cannot be hidden, supposedly sometime in the near future we will have the capability to hide these buttons, but for now, there is no native way to do it.
This is where XrmToolBox comes in.
You will need to Download it an Unzip on your computer. In the Unzipped folder, find the file called XrmToolBox.exe
and run it.
Click on the Tools tab and Search for Ribbon Workbench
.
If you do not see it, you will need to install it by clicking Open Tools Library.
I opened up Ribbon Workbench.
Note: You will need to create a connection your current Power Platform environment.
In the Load Solution screen I search for my How To Use Quick Create Solution
and click OK.
Yikes! Nasty error screen is displayed! Doesn’t like my Solution. I followed the recommended instruction on how to fix this error at https://ribbonworkbench.uservoice.com/knowledgebase/articles/169819, which involved creating a new Solution, which I called How To Use Quick Create Ribbon Workshop Solution
and added the Item table without any meta data.
I then hopped back over to XrmToolBox and clicked Open Solution, found my How To Use Quick Create Ribbon Workshop Solution
and clicked OK.
The initial load takes a bit, but when done, you can see all your command bars.
The top command bar is for the views, and I can see the two New buttons, neither of these are the one I created, so I’m going to hide them both, just for kicks and grins.
I right click on each of them and click Hide.
I then click Publish.
After it has published, I refresh my Model-Driven App and now there is just one New button, the one I added.
I do one last test, and everything checks out!
Not the easiest thing to do, but not terribly difficult! Looking forward to this being baked into the Model-Driven Apps sometime in the future!
If you have a better way, please share! 😊
Discover more from Matt Ruma
Subscribe to get the latest posts sent to your email.