Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Add command control on dynamic created ribbon buttons

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.");
}

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,101 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,908 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans