RSS

Tag Archives: Puja Jain

CRM 2013 – Refresh Associated Grid of an Entity

Introduction

Today I got a requirement to add a custom Ribbon Button in the SubGrid of Marketing List Entity and execute some logic and refresh the Grid. Last point was the trickiest one for me and that is why I decided to share the approach how to do it.

Steps

To achieve this, let’s go step by step.

Step-1: Create a JavaScript library that will be executed when Button is Clicked

function OpenLookUp(grid){
    //your logic

    //code that will refresh the grid
    grid.refresh();
}

Step-2: Add Custom Button using Ribbon Workbench and follow the Screen Shots

img1

img4
Select WebResource

Add the Selected Control as parameter.
img3

Step-3: Publish Solutions using Ribbon Workbench

Now the view will refresh after the Button is clicked.

By Puja Jain
Senior Software EngineerĀ @Team DynamicsCRM.
Mindfire Solutions

 
2 Comments

Posted by on December 27, 2013 in WebResources

 

Tags: , , , , , , , , , , , , , , , , , , , , , , , ,

CRM2011 Add Entity Level ‘Notes’ Section Accessible and Viewable from Custom HTML WebResources

Introduction

In this article, we will create an Entity level ‘Notes‘ Section accessible and viewable from Custom HTML WebResource.

Notes

Background

In one of my projects, there is a requirement to add a “Notes” Section to the custom HTML page, which will function same as entity level ‘Notes‘ in CRM. And that page is accessible from the Ribbon Button of an Entity form. I faced the challenge and figured out a way to do it.

Implementation

Steps which are needed to be followed:-

  • Create an HTML WebResource.
  • Add following Code to the row of table of your HTML page. Here my page is accessible through Order Level Form, hence Entity code is 1088.
    <tr style="height: 200px">
            <td colspan="4">
                <div id="tab6" class="ms-crm-InlineTab" isviewporttab="1">
                    <table style="height: 100%; width: 100%" class="ms-crm-InlineTabBody" cellspacing="0"
                        cellpadding="0">
                        <colgroup>
                            <col width="100%" />
                            <tbody>
                                <tr>
                                    <td valign="top">
                                        <div class="ms-crm-FormSection-Container">
                                            <table style="height: 100%; table-layout: fixed;" id="{19E2776E-C7EF-4ae2-99BB-549FF9DA0B23}"
                                                class="ms-crm-FormSection" cellspacing="0" cellpadding="3" columns="2" valign="top"
                                                isviewportsection="1" label="Notes">
                                                <colgroup>
                                                    <col width="115" />
                                                    <col />
                                                    <col width="115" />
                                                    <col />
                                                    <tbody>
                                                        <tr height="5">
                                                            <td>
                                                            </td>
                                                            <td>
                                                            </td>
                                                            <td>
                                                            </td>
                                                            <td>
                                                            </td>
                                                        </tr>
                                                        <tr height="25" valign="top">
                                                            <td style="height: 200px; overflow: hidden;" id="notescontrol_d" class=" FormSection_CellPadding"
                                                                rowspan="5" colspan="4" formxmlcolspan="2" isautoexpanding="TRUE">
                                                                <div style="display: none;" id="notescontrol_c" class="ms-crm-FieldLabel-LeftAlign ms-crm-Field-Normal"
                                                                    sl="false">
                                                                    <label for="notescontrol">
                                                                        Note Text</label></div>
                                                                <iframe style="width: 100%; height: 100%; min-height: 200px;" id="notescontrol" class="noteData"
                                                                    tabindex="51" src=""
                                                                    frameborder="0" name="notescontrol" scrolling="no" notesxml="" url="">
                                                                </ iframe>
                                                            </td>
                                                        </tr>
                                                        <tr height="25" valign="top">
                                                        </tr>
                                                        <tr height="25" valign="top">
                                                        </tr>
                                                        <tr height="25" valign="top">
                                                        </tr>
                                                        <tr height="100%" valign="top">
                                                        </tr>
                                                    </tbody>
                                                </colgroup>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </colgroup>
                    </table>
                </div>
            </td>
        </tr>
    
  • On load of your custom page add the following code.
    window.onload = function () {
         var iframe = document.getElementById('notescontrol');
         var entityId = window.parent.Xrm.Page.data.entity.getId();
         var noteUrl = document.location.protocol + "//" + document.location.host + "/" + Xrm.Page.context.getOrgUniqueName() + "/_controls/notes/notesdata.aspx?EnableInlineEdit=true&EnableInsert=true&id=%7b" + entityId + "%7d&ParentEntity=1088";
         iframe.src = noteUrl;
         iframe.url = noteUrl;
    }
    
  • Add your WebResource to your Ribbon ButtonorderRibbon
  • Finally we can see that the “Note” Section is created in your Custom Pageimg3

By Puja Jain
Senior Software EngineerĀ @Team DynamicsCRM.
Mindfire Solutions

 
2 Comments

Posted by on August 1, 2013 in WebResources

 

Tags: , , , , , , , , , , , , , , ,

Convert a Multiple Line of Text field to a Button using JavaScript

First of all create a new field of type “Multiple Lines of Text” and name it as “new_button“.
And also create a “JavaScript Webresource” and add the following method in onload event.
ButtonImage
function OnFormLoad() {
    ConvertTextFieldToButton('new_button', 'ButtonText', '100px', ButtonClickFunction, 'Button Label');
}
 
function ConvertTextFieldToButton(fieldname, buttontext, buttonwidth, clickevent, title) {
    if (document.getElementById(fieldname) == null) {
        return;
    }
 
    var functiontocall = clickevent;
    document.getElementById(fieldname).value= buttontext;
    document.getElementById(fieldname).readOnly = true;
    document.getElementById(fieldname).style.borderRight = "#3366cc 1px solid";
    document.getElementById(fieldname).style.paddingRight = "5px";
    document.getElementById(fieldname).style.borderTop = "#3366cc 1px solid";
    document.getElementById(fieldname).style.paddingLeft = "5px";
    document.getElementById(fieldname).style.fontSize = "11px";
    document.getElementById(fieldname).style.backgroundImage = "url(/_imgs/btn_rest.gif)";
    document.getElementById(fieldname).style.borderLeft = "#3366cc 1px solid";
    document.getElementById(fieldname).style.width = buttonwidth;
    document.getElementById(fieldname).style.cursor = "hand";
    document.getElementById(fieldname).style.lineHeight = "18px";
    document.getElementById(fieldname).style.borderBottom = "#3366cc 1px solid";
    document.getElementById(fieldname).style.backgroundRepeat = "repeat-x";
    document.getElementById(fieldname).style.fontFamily = "Tahoma";
    document.getElementById(fieldname).style.height = "20px";
    document.getElementById(fieldname).style.backgroundColor = "#cee7ff";
    document.getElementById(fieldname).style.textAlign = "center";
    document.getElementById(fieldname).style.overflow = "hidden";

    if(window.attachEvent)
    {
        document.getElementById(fieldname).attachEvent("onmousedown", MouseDown_button);
        document.getElementById(fieldname).attachEvent("onmouseup", MouseUp_button);        
        document.getElementById(fieldname).attachEvent("onclick", functiontocall);
    }
    else
    {
        document.getElementById(fieldname).addEventListener("mousedown", MouseDown_button, false);
        document.getElementById(fieldname).addEventListener("mouseup", MouseUp_button, false);        
        document.getElementById(fieldname).addEventListener("click", functiontocall, false);
    }

    document.getElementById(fieldname).style.lineHeight = "14px";
    document.getElementById(fieldname + '_c').style.visibility = 'hidden';
    document.getElementById(fieldname + '_d').style.width=buttonwidth;
    document.getElementById(fieldname +'_container').style.width="112px";
    document.getElementById(fieldname).title = title;
    window.focus();
 
    //Method Call on Mouse down
    function MouseDown_button(evt) {
       var eventer;   
  
       if(evt.srcElement)
       {
           eventer = evt.srcElement;
       }
       else
       {
           eventer = evt.target;
       }

       eventer.style.borderWidth = "2px";
       eventer.style.borderStyle = "groove ridge ridge groove";
       eventer.style.borderColor = "#3366cc #4080f0 #4080f0 #3366cc";
    }
 
    //Method Call on Mouse up
    function MouseUp_button(evt) {
       var eventer;   
  
       if(evt.srcElement)
       {
           eventer = evt.srcElement;
       }
       else
       {
           eventer = evt.target;
       }
        
       eventer.style.border = "1px solid #3366cc";
    }
}
 
function ButtonClickFunction() {
    //Method call on button click
}

Notes:
It also supports single line of text.

By Puja Jain
Senior Software Engineer @Team DynamicsCRM.
Mindfire Solutions

 
5 Comments

Posted by on April 25, 2013 in WebResources

 

Tags: , , , , , , , , , , , , , , , ,

 
%d bloggers like this: