Before you dive too deep in this I recommend you check out videos on how to install and use the Ribbon Workbench tool.
Click here for the link.
Also it is recommended to make changes through a Solution which I will not be covering either because there is a ton of information about that.
I will be adding more projects/examples as I verify the code is working properly.
Create button that will open quick create form
Let’s say I am in the Quote entity and I want to make a button that when clicked it opens the quick create form on a custom entity of mine (publisher_designrequest).
Here is the list of items I need to know:
Entities:
- quote
- publisher_designrequest (my custom entity)
Code:
function marketingdesignrequest(primaryControl) {
var thisAccount = {
entityType: "quote",
id: Xrm.Page.data.entity.getId()
};
var callback = function (obj) {
console.log("Created new " + obj.savedEntityReference.entityType + " named '" + obj.savedEntityReference.name + "' with id:" +
obj.savedEntityReference.id);
}
var setName = { };
Xrm.Utility.openQuickCreate("publisher_designrequest", thisAccount, setName).then(callback, function (error) {
console.log(error.message);
});
}
Step 1: Create a Web Resource
From CRM click the Setting icon in the right corner and click Advanced Settings
From there click Settings>Solutions
On the left find Web Resources then click New
Fill any identifying information you need then click Text Editor and past the above code in. Be sure to change your entityType and your entityLogicName to what you need.
Click Save and then Publish (I normally do this twice)
Step 2: Create the Button
Open Ribbon Workbench and load your solution
Select the quote Entity
Click the word Button and drag to where you want the button to be located
Click the + button on the right of command to add a command
Click Add Action>Javascript Action
Click Add parameter and select CRM Parameter
Next fill in the information:
- ID
- This can be named what you want
- Library
- Click the magnifying glass and find the Web Resource you created
- Function Name
- This is the name you used in the java script code above after the word Function on line 1
- CRM Parameter
- PrimaryControl is what I have in () on line one of the Javascript code. I will do some reading to see what this means.
Next click back to your button in the list under Buttons and fill in the info:
- ID
- The technical name you want for your button
- Command
- Select the command you created from the previous step
- Label
- This is friendly name the end user will see
- Image 16
- Click Magnifying glass and find an image
- Image 32
- Click Magnifying glass and find an image
- CommandCore
- I put the same name as the command name
At the top menu of Ribbon Workbench Click Publish and test
Now when I click on the Quotes entity I have a button that says Create DRF. When clicking it the Quick Create form comes up and Quote is automatically associated.
References:
https://carldesouza.com/opening-quick-create-javascript/
https://ribbonworkbench.uservoice.com/knowledgebase/articles/358664-create-a-command-bar-button-for-your-custom-acitiv
Execute Flow from a Button
What you will need:
- Power Automate Premium
- Ribbon WorkBench (I install this from XRM toolbox)
- SmartButtons
Here is a great article on how to create a custom button on an Entity that executes a flow
Call a Power Automate Flow from Custom button in CDS/D365 (d365geek.co.uk)
Below info is copied from the article for preservation. I can delete upon request.
Power Automate has a lot of advantages over Classic Workflows. I’ve given presentations on this topic and it’s an ongoing conversation piece in the community, of what everyone should be using. I’ve made a commitment to only build Power Automate Flows and NOT Classic Workflows anymore and it’s something I’m sticking to. One request on a lot of projects is the ability to click a button and some sort of automation happens. This has been available in CDS/D365 by choosing Run Workflow and choosing from a list but sometimes this is too many clicks or too complicated. This is where the Ribbon Workbench by Scott Durow is one of the best community tools available.
Scott Durow is a Microsoft MVP and the genius mind behind Sparkle XRM and the Ribbon Workbench. He is also the Chief Technology Officer and Co-Founder of Sales Spark, a new ISV for the Power Platform and D365 Sales, to turbocharge your sales. As a side note, Scott is the nicest guy you will meet.
Recently Scott has released an update to his SmartButtons solution, an addition to his Ribbon Workbench Tool which allows you to add buttons into CDS/D365’s Unified Interface, to do certain actions. These actions include running Reports, Workflows, JavaScript and a Webhook. The Webhook is what we are going to focus on because, if you have watched this video on my YouTube Channel, you will know that you can trigger a Flow to run.
THIS….IS….AMAZING news!! I don’t know how many implementations I’ve done where the customer has asked for just a single click button to run a workflow, but having the ability to do this using Power Automate is incredible. This opens up so many opportunities for us to do things using Flows. I thought, wouldn’t it be cool if we could run a flow on an account, take the address details, pass it to bing maps, retrieve the longitude and latitude and then update the record in CDS/D365. This blog is designed to help guide you through the process.
Firstly, download the smartbuttons solution from here and import it in your CDS/D365 instance. To do this, go to https://make.powerapps.com/ and navigate to solutions and choose “import” and follow the steps to install this solution.
Next you can either install the Ribbon Workbench solution into your environment or use the XrmToolBox tool for the Ribbon workbench, my default is always the XrmToolBox version. Details of how to install and use this can be found on the XrmToolBox site so I won’t go into configuring this.
Once you are all set up with these, it’s time to build your Flow! Go to Power Automate and create your Flow, which needs to be an “Automated – from Blank“ Flow. For the trigger, type in “request” and choose the “When a HTTP request is received” trigger.
Next, we need to write some JSON to retrieve the ID of the record or records we are running this Flow on, we’ll use this in the next step and it’s what we can use to identify the records up to update. Don’t worry, I’ve got the JSON right here:
{
“type”: “object”,
“properties”: {
“id”: {
“type”: “string”
}
}
}
Once you have pasted this in, we are going to use the CDS “Get record” action so that we can use some data from the records you want to run this on. In my example, i’m using the account record, but you can just select the entity you are using and then the identifier is the ID from the dynamic content.