RSS

Tag Archives: Dynamics CRM with Jquery

CRM 2013 JqGrid Theme

Behind the Scene

We built a Grid using a jqgrid Plugin in JavaScript for CRM 2011. That time the theme of the jqgrid was matching the CRM theme. But when we moved the solution to CRM 2013, the Grid was looking an odd one out as CRM 2013 Look and Feel was different.

Experiment

I tried to change the CSS of jqgrid and match it with the theme of CRM 2013, but found some problem with it. Then we have to remove the CSS used for the Grid and build a new CSS file for 2013.

Solution

The CSS, which were removed from the HTML page :-
1. jquery-ui-1.7.1.custom.css
2. ui.jqgrid.css (given in the jqGrid Plugin folder)

The CSS newly added for CRM 2013 is :- ui.jqgrid_custom.css (Custom build)
Feel free to click and download the CSS file and implement in your CRM projects.

Previously the Look was

jqPrevious

Now it has been Transformed to

jqGrid New

By Sukant Shekhar
Senior Software Engineer @Team DynamicsCRM.
Mindfire Solutions

Advertisements
 
 

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

Retrieve N:N Relationship Records using CrmFetchKit

Introduction

CrmFetchKit is a Cross Browser library that allows the execution of fecthXml queries via JavaScript for Dynamics CRM 2011 and CRM 2013 (using the new WCF Endpoints).

Background

In one of my recent projects, the requirement was to retrieve all Contacts present in a Campaign and to display all those in a Grid onload of Campaign record. As this process would fetch many records, so it should be Asynchronous.

Steps

Here are the steps how to use CrmFetchKit for retrieving records.

Step:1 Get the fetchXml using Advanced Find in Crm.

In my case, I used Advanced Find on Account Entity. Download the fecthXml and save it. It will be like below.

<?xml version="1.0"?>
<fetch distinct="true" mapping="logical" output-format="xml-platform" version="1.0"> 
    <entity name="contact"> 
        <attribute name="contactid"/>
        <attribute name="ownerid"/>
        <attribute name="fullname"/>
        <attribute name="lastname"/>
        <attribute name="telephone2"/>
        <attribute name="firstname"/>
        <attribute name="emailaddress1"/>
        <attribute name="createdon"/>
        <attribute name="new_city"/> 
        <order descending="false" attribute="ownerid"/> 
        <link-entity name="new_campaign_contact" intersect="true" visible="false" to="contactid" from="contactid"> 
        <link-entity name="campaign" to="campaignid" from="campaignid" alias="ab"> 
            <filter type="and">
                <condition attribute="campaignid" value="  campaignId  " uitype="campaign" 
 value="{8BE16D9E-8A7A-E211-B46D-00155D641D0E}"  operator="eq"/> 
            </filter> 
        </link-entity>
        </link-entity>
    </entity> 
</fetch>

Step:2 Add reference of fecthKit in the page where you are going to retrieve records.

<script src="../Scripts/jquery.1.7.1.min.js" type="text/javascript"></script>
<script src="../Scripts/CrmFetchKit.js" type="text/javascript"></script>

NB:The jQuery sholud be jquery.1.7.1.min.js (or higher).

Step:3 Add the code for retrieving Contacts present in a Campaign.

var contactData;
var campaignId;

campaignId = parent.Xrm.Page.data.entity.getId();

if(campaignId != null && campaignId != undefined)
{
    var fecthXMLForContact = '<fetch distinct="true" mapping="logical" output-format="xml-platform" version="1.0">'+
                             '<entity name="contact"> <attribute name="contactid"> <attribute name="ownerid">' +
                             '<attribute name="fullname"> <attribute name="lastname">' +
                             '<attribute name="telephone2"> <attribute name="firstname">' +
                             '<attribute name="emailaddress1"> <attribute name="createdon"> <attribute name="new_city">' +
                             '<order descending="false" attribute="ownerid">' +
                             '<link-entity name="new_campaign_contact" intersect="true" visible="false" to="contactid"   from="contactid">' +
                             '<link-entity name="campaign" to="campaignid" from="campaignid" alias="ab">' +
                             '<filter type="and"> <condition attribute="campaignid" value="' + campaignId + '" uitype="campaign" operator="eq">' +
                             '</condition></filter> </link-entity> </link-entity>' +
                             '</order></attribute></attribute></attribute></attribute></attribute>' +
                             '</attribute></attribute></attribute></attribute></entity> </fetch>';

     CrmFetchKit.Fetch(fecthXMLForContact).fail(function (xhr, status, errorThrown) {
         // get the error-message
         var msg = $(xhr.responseXML).find('Message').text();
         alert('Error occured: ' + msg);
     })
     .done(function (resultsContact) {
         contact = true;
         contactData = resultsContact;                
     });
}

In fetchXml, replace value of CampaignId with the Campaign Id for which you need to retrieve records.
The variable contactData will contain all records present in Campaign.
Here you are done!!!

By Gitanjali
Senior Software Engineer @Team DynamicsCRM.
Mindfire Solutions

 

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

Adding Tool Tips To Fields

Introduction

Tool tips can be added to the fields of the CRM form. It can be a static or dynamic tool tip.

Implementation

To implement this logic, we need Jquery.1.4.4.min.js file. You can get from here .

Create a  javascript web resource and add following functions in it.

function GetToolTips() {
    //Select Name Of Fields Whose ToolTips Is Recquird
    var fieldName1 = "telephone1";
    var fieldName2 = "telephone2";
    var fieldName3 = "fax";

    //Create Text To Be Shown In Respected Fields
    var textOfFieldName1 = "Tool Tip One";
    var textOfFieldName2 = "Tool Tip Two";
    var textOfFieldName3 = "Tolo Tip Three";

    //Calling Method To set Text On That Label Of Selected Field
    RegisterTips(fieldName1, textOfFieldName1);
    RegisterTips(fieldName2, textOfFieldName2);
    RegisterTips(fieldName3, textOfFieldName3);
}

function RegisterTips(fieldName, textOfField) {
    var obj = document.getElementById(fieldName + '_c').children[0];

    // construct tooltip text according to attribute name
    html = '</pre>
<div id="tooltip_' + fieldName + '" style="visibility: hidden; position: absolute;">: ' + textOfField + '</div>
<pre>
';

    $(obj).append(html); // append tooltip text with label
}

Add  jquery.1.4.4.min.js file as web resource.

In the “account” form property, add  both the Web Resources.

In the Onload event of  the account form call the GetToolTips() function and see the tool tip will be reflected when the mouse points to that fields as shown below.

Capture capture2

Hope it helps you……

By Ranjan Parhi
Senior Software Engineer @Team DynamicsCRM.
Mindfire Solutions

 
 

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

 
%d bloggers like this: