Showing Total in Footer in jqGrid.

Hi,

We recently had a requirement to show total for 2 of our decimal columns in jqGrid.

We need to set the following properties footerrow and userDataOnFooter and the a function on loadComplete of grid

Hope it helps..

Fixed – Grid can not be used in this (‘quirks’) model in jqGrid

We got the above error in an HTML Web Resource which was using jqGrid. The page was working fine in IE 10 browser only in IE 8 we got that error.

The solution was to use the following meta tag inside the HEAD tag of the html page.


<meta
http-equiv=”X-UA-Compatible”
content=”IE=edge”
/>

More details on this meta tag

http://stackoverflow.com/questions/6771258/whats-the-difference-if-meta-http-equiv-x-ua-compatible-content-ie-edge-e

Hope it helps.

Fixed – Expected identifier, string or number error in HTML Web Resource in IE.

We recently developed an html web resource which was using jqGrid. The web resource was working properly on machines having IE 10 browser, but got the above error in case of IE 8.

As it turned out extra “,” i.e. trailing comma was the reason for the error.

Removing it fixed the issue. IE 10 was more forgiving.

Hope it helps.

‘_formHierarchy’ is undefined error in CRM 2011

Hi,

We recently faced this issue while opening one of our entity’s form.

This issues comes if we have specified bracket while defining JavaScript function on form.

For e.g. CheckFinancialStatus()

Changing it back to
CheckFinancialStatus resolved the issue.

Hope this helps.

Object doesn’t support property or method selectNodes error in JavaScript in CRM 2011

We got the below error in one of our CRM entity form’s onload JavaScript. The same was working fine in IE9.

Similarly in Chrome and Firefox also we were getting the below error.

Finally we came to know it was because XPath is not supported in IE 10 and other browsers.

Get the more details here

http://www.w3schools.com/xpath/xpath_examples.asp

Hope it helps

Showing related entity information in Header as Hyperlink – CRM 2011

We recently had requirement to show the Case Information in one of its related (related) entity’s header. The information should appear as a hyperlink so that users can open the case directly from that entity’s form.

Case entity was having 1-n relationship with this other entity say Entity A and Entity A was related 1-n with Entity B. In Entity A we had moved the lookup of Case in the header. So from Entity A’s form user could click the lookup in header (as lookup appeared as hyperlink in Header) and open the Case.

Now they wanted the similar kind of functionality in Entity B. However as Entity B was not directly related to Case entity it had no lookup or any other field having Case information in it.

So this is what we did :-

  1. Created a new HTML Web Resource.
  2. Added an anchor tag in it.
  3. Used JavaScript to get the Case Information from the lookup of the Entity A in the form.
  4. Dynamically setting the href and innerHTML of the anchor tag so that it provides case information and link clicking on which should open the case record.
  5. Add the Web Resource in the header of the Entity B form.
  6. As we were using JSON here, added the JSON library in the form load.

    Case Information in the header and the hyperlink:-

Sample Code of the HTML Web Resource:-


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <title>Case Information</title>
 <script src="ClientGlobalContext.js.aspx"></script>
 <script type="text/javascript" src="new_json2"></script>
 <style type="text/css">
 .ms-crm-Field-Normal
 {
 font-family: Segoe UI, Tahoma, Arial;
 font-size: 13px;
 position:absolute;
 top:0px;
 text-align: left;
 }


 </style>
 <meta charset="utf-8">
</head>
<body style="background-color: #f7fbff; margin: 10px" onload="GetCaseInformation()"
 contenteditable="true">
 <a id="anchorCase" href="#" target="_blank" class="ms-crm-Field-Normal"></a>
 <script>

var FORM_TYPE_UPDATE = 2;
 var FORM_TYPE_READ_ONLY = 3;
 var FORM_TYPE_DISABLED = 4;


 var ODataPath;
 var serverUrl;
 var entityName = "";
 var id = "";
 var entity;

function GetCaseInformation() {
 init();
 }

function init() {


 serverUrl = document.location.protocol + "//" + document.location.host + "/" + Xrm.Page.context.getOrgUniqueName();
 ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
 if (parent.Xrm.Page.ui.getFormType() == FORM_TYPE_UPDATE ||
 parent.Xrm.Page.ui.getFormType() == FORM_TYPE_READ_ONLY ||
 parent.Xrm.Page.ui.getFormType() == FORM_TYPE_DISABLED) {

// get the lookup control and its guid and entity type
 var value = parent.Xrm.Page.ui.controls.get('new_casemedicalconditionid').getAttribute().getValue();

if (value != null) {
 id = value[0].id.replace('{', '').replace('}', '');
 entityName = value[0].entityType;
 }
 }
 // get the case information
 retrieveRecord(id);
 }

function retrieveRecord(Id) {
 var retrieveReq = new XMLHttpRequest();
 var url = ODataPath + "/" + entityName + "Set(guid'" + Id + "')";

retrieveReq.open("GET", ODataPath + "/" + entityName + "Set(guid'" + Id + "')", true);
 retrieveReq.setRequestHeader("Accept", "application/json");
 retrieveReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
 retrieveReq.onreadystatechange = function () {
 retrieveReqCallBack(this);
 };
 retrieveReq.send();
 }

function retrieveReqCallBack(retrieveReq) {


 if (retrieveReq.readyState == 4 /* complete */) {
 if (retrieveReq.status == 200) {
 //Success

 entity = JSON.parse(retrieveReq.responseText).d;
 if (entity.new_CaseId != null) {
 var caseGuid = entity.new_CaseId.Id;
 var caseName = entity.new_CaseId.Name;
 var serverUrl = document.location.protocol + "//" + document.location.host + "/" + Xrm.Page.context.getOrgUniqueName();
 if (document.getElementById('anchorCase').innerHTML == "") {
 document.getElementById('anchorCase').innerHTML = caseName;
 document.getElementById('anchorCase').href = serverUrl + "/CS/cases/edit.aspx?id={" + caseGuid + "}";
 }
 }
 }
 }
 }

</script>
</body>
</html>


Bye.

querySelector and querySelectorAll – Selectors API

Hi,

Apart from our usual document.getElementsById and document.getElementsByTagName method to select element from the DOM we can now make use of document.querySelector and document.querySelectorAll .

With them we can use the same selectors that we use in CSS to select elements for styling.

A simple example

<html>
<head>
    <title>Selectors API</title>
    <script>
        window.onload = function () {

            // select div element with id myDivId
            var myDiv = document.querySelector("#myDivId");

            // select p element with text "Paragraph 1"
            var paragraph1 = myDiv.querySelector("span>p");

            // select p element having class as p1Class
            var paragraph2 = document.querySelector("p.p2Class");

            // select all p element
            var allParagraph = document.querySelectorAll("div>span>span>p");
        }

    </script>
</head>
<body>
    <div id="myDivId" class='divClass'>
        <span><span class='spanClass'>
            <p>
                Paragraph 1</p>
            <p id="p2" class="p2Class">
                Paragraph 2</p>
        </span></span>
    </div>
</body>
</html>

More details

http://msdn.microsoft.com/en-us/ie/cc307217.aspx

http://msdn.microsoft.com/en-us/library/cc288326(v=vs.85).aspx

Browser supported

http://caniuse.com/queryselector

Making cross domain call using JSONP (JSON with padding)

Hi,

Just created a simple html page that uses JSONP to make cross domain call to twitter’s API.

Source Code:-

<!DOCTYPE html>
<html>
<head>
    <title>JSONP Example</title>
    <script>

        function getTweets(tweets) {

            var tweetDiv = document.getElementById("tweet");

            for (var i = 0; i < tweets.results.length; i++) {
                var tweet = tweets.results[i];

                // create div element for each result
                var div = document.createElement("div");
                div.innerHTML = "<img src= " + tweet.profile_image_url + "></img> ";
                div.innerHTML += tweet.from_user + " : <b><i>" + tweet.text + "</b></i>";

                // append it to tweet div
                tweetDiv.appendChild(div);
            }
        }
    </script>
</head>
<body>
<div id="tweet">
</div>
<!--Specifying search term and callback function-->
<script src="http://search.twitter.com/search.json?q=Sachin%20Tendulkar&rpp=10&callback=getTweets"></script>
</body>
</html>

Bye

Error: ‘VEMap’ is undefined

If we get the above error while working with Virtual Earth first thing we need to check is whether the internet connection is working or not.

Next thing to check is whether JavaScript is disabled for the browser. And if this is the case, to enable it in case of IE.

Go to Tools à Internet Options à Security Tab

Find the entry Active Scripting and enable it.

Hope it helps.

Get QueryString values in JavaScript

Hi,

We can make use of the following functions to get the value of querystring parameters through JavaScript

// helper function to get the query string
function Querystring() {

var querystring = location.search.substring(1, location.search.length);

var args = querystring.split(‘&’);

for (var i = 0; i < args.length; i++) {

var pair = args[i].split(‘=’);

 temp = unescape(pair[0]).split(‘+’);

 name = temp.join(‘ ‘);
temp = unescape(pair[1]).split(‘+’);
value = temp.join(‘ ‘);
this[name] = value;
}
this.get = Querystring_get;

}

function Querystring_get(strKey, strDefault) {
var value = this[strKey];
if (value == null) {
value = strDefault;
}
return value;
} 

Suppose our current page url is

http://mycustompage/home.aspx?id=1020

To get the value for id we’ll do this

var qs = new Querystring();

var idValue=qs.get(“id”, “”);

 Bye..