PhuocLe - Microsoft Dynamics CRM

Category:  CRM

CRM Grid Plus 1.4.1 Nov/15/2016

What new for this release

  • Supported Dynamics 365
  • Not supported Dynamics 365 Editable grid, Read-only grid can formatted
  • Enhance loading performance

Download: https://crmgridplus.codeplex.com

Category: CRM

CRM Grid Plus 1.4 Oct/05/2016

What new for this release

  • Added format dialog for easy format, before you should typing the format css code.
  • Merge download solution files, now only one solution file, supportted CRM 2013 SP1 and later
  • Fixed bugs: ribbon button text show incorrect when not English language.

Download: https://crmgridplus.codeplex.com

Category: CRM

CRM Grid Plus 1.3.6 Sep/20/2016

What new for this release

  • Added popup select color
  • Added build-in function: ADD_DAYS
  • Added parameters: CURRENT_MONTH, CURRENT_YEAR
  • Added operator BETWEEN on DateTime column

Download: https://crmgridplus.codeplex.com

Category: CRM

Hide Next Stage, Set Active, Back Button in Business Process Flows Aug/16/2016

I have a requirement in my current project that hide Next Stage, SetActive and Back button in the Business Process Flows

To do that, I used an unsupported code below.

function hideBPFButton() {
    hideBPFButtons();
    window.addEventListener("resize", hideBPFButtons);
    Xrm.Page.data.process.addOnStageSelected(hideBPFButtons);
}

function hideBPFButtons() {
    var dom = (Xrm == undefined || Xrm.Internal == undefined || Xrm.Internal.isTurboForm() == undefined || Xrm.Internal.isTurboForm() == false) ? document : parent.document;
    $("#stageSetActiveActionContainer", dom).remove();
    $("#stageBackActionContainer", dom).remove();
    $("#stageNavigateActionContainer", dom).remove();
    setTimeout(function () { $("#processStagesContainer", dom).width(1894); }, 50);
}

In the form OnLoad, call function

hideBPFButton();

Before apply code

 

After apply code

 

 

How to program change stage, set active, ....

  • Client side: check Xrm.Page.data.process and Xrm.Page.ui.process
  • Server side: reference 3 fields in the entity record, update these fields and update entity record.
    • processid
      • query processid by Process Name in entity workflow
        
          
            
            
              
              
              
            
          
        
    • stageid
      • query stageid by processid and Stage Name in entity processstage
        
          
            
            
              
              
            
          
        
    • traversedpath
      • combine entity id string. Eg. in this case leadid,opportunityid,quoteid,salesorderid (seperator use comma)

Checked, Tested work with CRM2016, CRM2016 SP1, CRM2016 Online

Unsupported code, use it with your own risk.

Category: CRM

Add more buttons in the form sub-grid Aug/10/2016

Sometime, your business requirement need add some buttons in the form sub-grid like picture below (Account form, sub-grid Contacts).

How I can do that

1. Prepare 2 web-resource png image 16x16 file.

  • 1 for normal button
  • 1 for hover button

2. Copy function below to your main js web-resource file

function createButton(grid, buttonName, buttonTooltip, buttonImage, buttonImageHover, callback) {    
    if (grid == null || grid.length == 0) return;
    if (buttonName == null || buttonName.length == 0) return;
    if (buttonImage == null || buttonImage.length == 0) return;    
    var dom = (Xrm == undefined || Xrm.Internal == undefined || Xrm.Internal.isTurboForm() == undefined || Xrm.Internal.isTurboForm() == false) ? document : parent.document;   
    var button = dom.getElementById(grid + "_addImageButton");
    if (button == null || button.parentNode == null || button.parentNode.parentNode == null) return;
    var tooltip = "";
    if (buttonTooltip != null && buttonTooltip.length > 0) 
        tooltip = " title='" + buttonTooltip + "' alt='" + buttonTooltip + "' ";    
    var div = dom.createElement("div");
    div.className = "ms-crm-contextButton";
    div.innerHTML = "<a href='#' id='" + buttonName +"' style='display:block;cursor:pointer;'" + tooltip + "><img id='"+ buttonName +"Image' src='" + buttonImage + "'" + tooltip + "></a>";
    button.parentNode.parentNode.appendChild(div);
    if (buttonImageHover != null) {
        dom.getElementById(buttonName).onmouseover = function () {
            dom.getElementById(buttonName + "Image").src = buttonImageHover;
        }
        dom.getElementById(buttonName).onmouseout = function () {
            dom.getElementById(buttonName + "Image").src = buttonImage;
        }
    }
    dom.getElementById(buttonName).onclick = callback;
}

Noted: this function already check Turbo form or not

3. On the on-load form, add the following code to add button to form sub-grid

createButton("Contacts", "btnViewChart", "View Chart", "../WebResources/pl_chart.png", "../WebResources/pl_chart_hover.png", function() {
    alert("View Chart Click");
});

Function parameters

  • grid: is the name of the sub-grid you add on form, in this case: Contacts, (required)
  • buttonName: because you can add more buttons, so you need enter the unique buttonName, in this case: btnViewChart (required)
  • buttonTooltip: the tooltip of this button, in this case: View Chart (optional)
  • buttonImage: the normal image button that you prepare in step 1, in this case: ../WebResources/pl_chart.png (required)
  • buttonImageHover: the hover button that you prepare in step 1, in this case: ../WebResources/pl_chart_hover.png (optional)
  • callback: a callback function after user click on button. (required)

4. Published and tested. I already tested on CRM2016 SP1 and CRM2016 Online.

Again, unsupported code, use it with your own risk.

Category: CRM