Create Ribbon on subgrid and selected record on show button

 1.  create button.

2. Add command.

3. Add enable rule



Hide Rule




function updateStatus(selectedrecord, formContext, commandProperties) {

       debugger;

       //alert("Called Javascript");

       if (commandProperties.SourceControlId.includes("EOL.Button")) {

              update(selectedrecord, "EOL")

       }

       else if (commandProperties.SourceControlId.includes("Respite.Button")) {

              update(selectedrecord, "Respite")

       }

       else if (commandProperties.SourceControlId.includes("NotResident.Button")) {

              update(selectedrecord, "NotResident")

       }

 

       setTimeout(function () {

              formContext.getControl("Survey_Excluded").refresh();

              formContext.getControl("Interview").refresh();

       }, 5000);

}

 

 

 

unction update(selectedrecords, type) {

       for (let i = 0; i < selectedrecords.length; i++) {

 

              if (type == "EOL") {

                      process(selectedrecords[i], "806460000");

              }

              else if (type == "Respite") {

                      process(selectedrecords[i], "806460005")

              }

              else if (type == "NotResident") {

                      process(selectedrecords[i], "806460004")

              }

       }

}

 

 

function process(id, excludedreason) {

 

       var entity = {};

       entity["ecl_interviewstatus"] = 806460003;

       entity["ecl_excludedreason"] = excludedreason;

 

       Xrm.WebApi.updateRecord("ecl_interview", id, entity).then(function success(result) {

              debugger;

              console.log("status updated");

              // perform operations on record update

       }, function (error) {

              debugger;

              console.log(error.message);

              // handle error conditions

       });

 

}

 

 

function HideButton(formContext) {

       debugger;

       var interviewstatus = formContext.getAttribute("ecl_interviewstatus").getValue();

       if (interviewstatus == 806460002) {

              return true;

       } else {

              return false;

       }

}


Comments

Popular posts from this blog

Power Automate compose vs variable

Update record when checkbox checked using JavaScript and save d365

Power pages custom button add in gried