Thursday, April 7, 2016

Insert Image in knowledge base article

Insert Image in knowledge base article

1.       Create one Image (PNG/JPG/GIF) type web resource into CRM system.
2.       Upload image you want to show in article into Web resource.
3.       Save your image web resource.
4.       Once you save your web source, CRM shows direct URL for that web resource.

5.       Open your article where you want to insert image, and also open image resource in another browser window using web resource URL.
6.       Now simply drag image to Article.

7.       Save and publish article
8.       Now article will show image.



Tuesday, May 19, 2015

Hide / Show Export to Excel button for specific Entity / Specific View

In MS CRM, Export to excel feature is enabled or disabled from security role.
You can have this feature for all applicable entities or none of the entity.
But sometime we have requirement to hide export to excel from particular entity, or show only for particular entity.
With Security role this requirement is not possible, but will little JavaScript code and ribbon customization we can achieve this.

Case 1: Hide Export to Excel button from contact Home grid.

1.      Create one custom solution
2.      Add Application Ribbons – from client Extensions





3.      Create one JavaScript web resource in this solution and add following code

function ShowHideExport2Excel(SelectedEntityTypeName) {
    if (SelectedEntityTypeName == 'contact')
        return false// hide button
    else
        return true//show button
}

4.       Now Open this custom solution into Ribbon workbench
5.      In the Entities list you will see ApplicationRibbon
6.      Select Export to Excel button from Home, right click and Customize command



7.      In Commands, you will see Mscrm.ExportToExcel
8.      Now add custom Enable Rule to this command. Keep existing enable rules.
9.      When adding enable rule, add Custom JavaScript rule.
Default: True
FunctionName: ShowHideExport2Excel
invertResult: False
Library: your JavaScript library
Parameters :  [Crm Parameter] = SelectedEntityTypeName

10.  Add Crm Parameter to Custom JavaScript rule, value of this parameter must be SelectedEntityTypeName

11.   Save and publish your customization.
12.  Now Export to Excel button is hidden for Contact home grid.

Export To Excel button is not showing now.



 Export To Excel button is showing now.



Case 2: Show Export to Excel button only for contact Home grid.

In this case you just need to change JavaScript code little bit as

function ShowHideExport2Excel(SelectedEntityTypeName) {
    if (SelectedEntityTypeName == 'contact')
        return true// show button
    else
        return false//hide button
}


Case 3: Show Export to excel button for particular entity and particular view only

[To do this need to use Unsupported JavaScript code]
To do this, we need to add one more Crm parameter to enable rule, and select value to this parameter is SelectedControl



And modify JavaScript function as

For MS CRM 2013 :

function ShowHideExport2Excel(SelectedEntityTypeName, selectedCtrl) {
    if (SelectedEntityTypeName == 'contact') {
        var view = selectedCtrl.get_$1X_3();
        var viewName = view.selectedViewName;
        if (viewName == 'My Active Contacts') //Change "My Active Contacts" with Your view name to show Export To Excel button
            return true; // show button
        else
            return false; // hide button
    }
    else
        return true;
       
}

For MS CRM 2015:

function ShowHideExport2Excel(SelectedEntityTypeName, selectedCtrl) {
    if (SelectedEntityTypeName == 'contact') {        
        var viewName = selectedCtrl.get_viewTitle();
        if (viewName == 'My Active Contacts'//Change "My Active Contacts" with Your view name to show Export To Excel button
            return true// show button
        else
            return false// hide button
    }
    else
        return true;
       
}

Wednesday, May 6, 2015

Running CRM Dialog from Custom Ribbon button


 1.      Add custom button on form
Say Run Dialog


     2. Now create command for custom button

     3. Add  Action to command

For the action add “Open Url Action”



3. For Url Command set your dialog URL
         To get dialog URL run dialog using “Start Dialog” button


Then select dialog you want to run on button click, once dialog started copy URL of dialog from address bar



 5. Your dialog url will be look like 

https://{CRM Server}:444/cs/dialog/rundialog.aspx?DialogId=%7b83D90936-EBEC-4CE5-8A58-A1530DE30680%7d&EntityName=new_test&ObjectId=%7b0FCB7F66-5FA6-E411-B1DF-0050568C6D7D%7d

It has Dialogid, Entityname and ObjectId
ObjectId is the record id on which this Dialog is running.

 6. If you use this URL as it is on button command then dialog will be run on same record again and again. 

      7.  To pass ObjectId / record id dynamically, need to pass one parameter to Url command, defined for custom button. This parameter should be like




    8. Now update your URL command address to

https://{CRM Server}:444/cs/dialog/rundialog.aspx?DialogId=%7b83D90936-EBEC-4CE5-8A58-A1530DE30680%7d&EntityName=new_test

Noticed that I removed &ObjectId=%7b0FCB7F66-5FA6-E411-B1DF-0050568C6D7D%7d, this objectId is passed by parameter, that’s why Parameter Name is important. 

    9.  Save and publish your customization.


   10.   Now dialog will be run for record you are in from button.