web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Add command control on dynamic created ribbon buttons

(0) ShareShare
ReportReport
Posted on by

Hi Expert,

Clicking a custom button to trigger a logic app flow has been finished by using ribbon work. Now I'm required to create every button with the name dynamically.   Refer the Mahsud's Dynamics CRM Blog, the post: Dynamically Populating Ribbon Flyout Menu in Unified Interface ( http://siddiquemahsud.blogspot.com/2019/09/dynamically-populating-ribbon-flyout.html?m=1 ), I can create dynamic button.

The question is I need to click any created button to trigger a flow, how to add a command control to the button once it created. One of possible solution is change Xml file, add trigger flow command on the button, but I don't know how to do it.

Could you help me? thank you in advance. The code from Mahsud's Dynamics CRM Blog as below (Beside highlight command I need to add another command to trigger flow )

function populateEnrollmentFlyout(commandProperties) {
    var programsRibbonXml = "";
    var programs = retrieveMultiple('msd_programs'"?$select=msd_programid,msd_name");

    var command = "msd.lead.Command.ProgramClicked";

    //This code is used to build the command string for UCI
    if (commandProperties.SourceControlId != null) {
        var source = commandProperties.SourceControlId.split('|');
        if (source.length > 3) {
            //command="lead|NoRelationship|Form|msd.lead.Command.ProgramClicked"
            command = source[0] + "|" + source[1] + "|" + source[2] + "|" + command;
        }
    }
    programsRibbonXml += "<MenuSection Id='msd.Lead.Programs.MenuSection' Sequence='10'><Controls Id='msd.Lead.Programs.Control'>"
    if (programs != null) {
        for (var i = 0i < programs.lengthi++) {
            var Name = programs[i].msd_name;
            var Value = programs[i].msd_programid;
            programsRibbonXml += "<Button Id='" + Value + "' Command='" + command + "'  Sequence='" + ((i + 1) * 10) + "' LabelText='" + Name + "' />"
        }
    }
    programsRibbonXml += "</Controls></MenuSection>";
    commandProperties["PopulationXML"] = '<Menu Id="msd.Lead.Programs.Menu">' + programsRibbonXml + "</Menu>";
}

function programClicked(commandProperties) {
    alert("program with id " + commandProperties.SourceControlId + " selected.");
}
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 74 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 55 Most Valuable Professional

#3
Anthony Blake Profile Picture

Anthony Blake 43 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans