Using HTML Web Resource in CRM 2011


Just created a simple html page to see how we can use it in CRM 2011.

The page is on account form and shows name of the account. It also accesses ClientGlobalContext.js file to show contextual information like Organization Unique Name and User Id of the user.

The html page:-

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<!--

Access the ClientGlobanContext js file

src="ClientGlobalContext.js.aspx"  if the html web resource doesn't follow any folder structure
i.e. http://servername/orgname/WebResources/new_myHtmlWebResource

src="../ClientGlobalContext.js.aspx" if the html web resource follows folder structure
i.e. http://servername/orgname/WebResources/new_myfolder/myHtmlWebResource

-->

<script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>
<script type="text/javascript">

    function ContextInformation() {

        // accessing attributes in the form  window.parent.Xrm.Page
        document.getElementById('td1').innerHTML = window.parent.Xrm.Page.getAttribute('name').getValue();

        var context = GetGlobalContext();
        // or by using  window.parent.Xrm.Page.context
        document.getElementById('td2').innerHTML = context.getOrgUniqueName();
        document.getElementById('td3').innerHTML = context.getUserId();
    }

</script>
    <title>My HTML Web Resource</title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 147px;
            font-weight: bold;
        }
        .style3
        {
            width: 478px;
        }
    </style>
</head>
<body onload="ContextInformation();">

    <table class="style1">
        <tr>
            <td class="style2">
                Account Name:-</td>
            <td class="style3" id="td1">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style2">
                Organization Name:-</td>
            <td class="style3" id="td2">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style2">
                User Id:-</td>
            <td class="style3" id="td3">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>

</body>
</html>



Points to remember
Access the ClientGlobanContext js file

src=”ClientGlobalContext.js.aspx” if the html web resource doesn’t follow any folder structure
i.e. http://servername/orgname/WebResources/new_myHtmlWebResource

src=”../ClientGlobalContext.js.aspx” if the html web resource follows folder structure
i.e. http://servername/orgname/WebResources/new_myfolder/myHtmlWebResource

and using window.parent.Xrm.Page to get the reference to the Xrm.Page from the html web resource

Hope it helps.

 

Updated SDK Version 5.0.7 available


The updated version of the SDK is available for download CRM 2011 SDK 

IETester Tool for testing applications in different versions of IE.


Recently we had built a web application using ASP.NET MVC 3, and had used Regular Expression for checking of password strength.

“^(?=.*[(\W)_]).{8,}$”

The above expression checks for password length to be minimum 8 characters and one special character.

It was working fine in IE 8 and IE 9. However we had our users using IE 7 as well, in which it was not working properly. As we were having our machine running Windows 7 and Windows Server 2008, it was not possible to have IE 7 installed in it. However recently going through one of the blog I have subscribed to I came to know about a tool which we can use to test our application in IE 7.

IE Tester tool:-

http://www.my-debugbar.com/wiki/IETester/HomePage

The helpful post:-

http://blog.customereffective.com/blog/2011/10/crm-2011-cases-knowledgebase-articles-and-ie-7.html

Hope it helps.

Cleared MB2 866 Microsoft Dynamics CRM 2011 Customization and Configuration Exam


Today I cleared my first CRM 2011 certification exam. It had total 75 questions and duration was of 140 minutes.

One thing different from CRM 4.0 or CRM 3.0 exams was that the in the case of multiple choice questions, there were no “select 2” or “select 3” correct answers, it was “Select all that apply”. In some cases i think there was only one correct answer for “Select all that apply” questions.

Well, talking about topics, there were more than 15 – 20 questions on Solutions only, especially managed solution and managed properties followed by around 10 questions on Audit and Field Security. Then few around new features in Business Unit, Teams and Security Roles.

Go through the helpful tips given here

http://www.dynamicscrmtrickbag.com/2011/09/12/preparing-for-exam-mb2-866-microsoft-dynamics-crm-2011-customization-and-configuration/

And following is the link to the posts that I used as notes while preparing for the exam.

https://nishantrana.wordpress.com/category/crm/crm-2011/new-features/

Hope it helps.

Changes in System Setting in CRM 2011.


The number of tabs has increased from 7 to 10 in CRM 2011 from CRM 4.Preview post

The new tabs added are

Calendar, Auditing and Goals.

Now let’s first start with the General Tab and options therein.

GENERAL TAB:-

There are two more options added in CRM 2011 in General tab are

The Get Started Pane in CRM 2011.

IM Presence can be set from General system settings.

CALENDAR:-

If we try saving an appointment record with duration more than 10 days we get the warning that “duration of the appointment is invalid”


There was no such option in CRM 4.0.

FORMAT:-


No change here.

AUDITING:-

From here we can enable auditing for the system. This feature was not there in CRM 4.0.


E-MAIL:-

CRM 4:-


CRM 2011:-


The new feature is setting option for Use Smart Matching. It is very nicely explained here

http://mscrmspot.blogspot.com/2011/05/crm-e-mail-setting-deep-dive.html

MARKETING:-

No changes in CRM 2011.


CUSTOMIZATION:-

In CRM 4


We could set the Prefix here in CRM 4, now this option has moved to Solutions where we can define prefix for Publisher of the solution.

Custom menus and toolbars: – This can be governed through RibbonDiffXml for entities and Application Ribbon for the application.

In CRM 2011, the only option is of Application mode.

OUTLOOK:-

Things are same for CRM 4 and CRM 2011, the only new option in CRM 2011 is whether user sees get the outlook client message in the Message bar or not.


REPORTING:-

No changes in Reporting tab


GOALS:-

Goals is a new feature in CRM 2011.


Check this wonderful post on system settings:-

http://www.avanadeblog.com/xrm/2010/12/crm-2011-feature-of-the-week-system-systems-whats-new.html

Hope it helps.

Account Search based on account name through a ribbon button on account grid in CRM 2011


Hi,

Just created a simple managed solution that will show a button on Account’s grid. It will only get enabled when only one record is selected in grid otherwise it would remain disabled.

For that we can use SelectionCountRule in our EnableRule definition.

On click of button we are calling a JavaScript function and passing guid of the record selected using CrmParameter as the part of JavaScriptFunction Action.

The JavaScript function uses that guid, makes a OData call and retrieves the account name and passes that account name as a query parameter to google search url and uses window.open method to open the page.

RibbonDiffXml for that:-

<RibbonDiffXml>
        <CustomActions>
          <CustomAction Id="MyOrg.CustomAction" Location="Mscrm.HomepageGrid.account.MainTab.Collaborate.Controls._children" Sequence="1">
            <CommandUIDefinition>
              <Button Id="MyOrg.Button" ToolTipTitle="Search in Google" ToolTipDescription="Search detail of the account selected" Command="MyOrg.Command" Sequence="1" LabelText="Search in Google" Alt="Search in Google" Image16by16="$webresource:new_search16" Image32by32="$webresource:new_search32" TemplateAlias="o1" />
            </CommandUIDefinition>
          </CustomAction>
        </CustomActions>
        <Templates>
          <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
        </Templates>
        <CommandDefinitions>
          <CommandDefinition Id="MyOrg.Command">
            <EnableRules>
              <EnableRule Id="MyOrg.EnableRule"></EnableRule>
            </EnableRules>
            <DisplayRules />
            <Actions>
              <JavaScriptFunction Library="$webresource:new_search" FunctionName="search">
                <StringParameter Value="Guid Selected"></StringParameter>
                <CrmParameter Value="SelectedControlSelectedItemIds"></CrmParameter>
              </JavaScriptFunction>
            </Actions>
          </CommandDefinition>
        </CommandDefinitions>
        <RuleDefinitions>
          <TabDisplayRules />
          <DisplayRules />
          <EnableRules>
            <EnableRule Id="MyOrg.EnableRule">
              <SelectionCountRule AppliesTo="SelectedEntity" Maximum="1" Minimum="1"></SelectionCountRule>
            </EnableRule>
          </EnableRules>
        </RuleDefinitions>
        <LocLabels />
 </RibbonDiffXml>
 

JavaScript:-

function search(message,value)
{
var  Id = value;
var serverUrl = Xrm.Page.context.getServerUrl();
var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";

var retrieveAccountReq = new XMLHttpRequest();
retrieveAccountReq.open("GET", ODataPath + "/AccountSet(guid'" + Id + "')", false);
retrieveAccountReq.setRequestHeader("Accept", "application/json");
retrieveAccountReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");

retrieveAccountReq.onreadystatechange = function () {
  retrieveAccountReqCallBack(this);
 };

retrieveAccountReq.send();
}

function retrieveAccountReqCallBack(retrieveAccountReq) {

  if (retrieveAccountReq.readyState == 4) {
  if (retrieveAccountReq.status == 200) {

 var accountName = eval('('+retrieveAccountReq.responseText+')').d.Name;
 window.open("http://www.google.com/search?q="+accountName);
}
  else {
     alert("Call Failed.");
  }
 }
}

The managed solution:-

https://nishantrana.me/wp-content/uploads/2011/10/accountsearch_1_0_0_0_managed.doc

Just change the extension to zip from doc.

Hope it helps!

 

Nishant Rana's Weblog

Everything related to Microsoft .NET Technology

Skip to content ↓