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 = 0; i < programs.length; i++) {
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.");
}