Search

Friday, February 12, 2010

Connect to CRM Web Service without impersonation

Today I'm doing CRM deployment to another server/organization. I get "The request failed HTTP status 401: Unauthorized"

I scratched my head about 2 hours. Double confirmed x 100 times on my CRM service account's access, permission. There are all fine and nothing wrong with that.

Finally, I found a very intersting KB from Microsoft.
http://support.microsoft.com/kb/948746

Wohh, now I only know the root cause.
"To work around this problem, use Deployment Manager to change the name of the organization so that the display name of the organization does not contain blank spaces."

Alternatively, I found out that, without changing in Deployment Manager, we can remove the blank space of organization name when calling the CRM Web Service. (eg, My Org to MyOrg).

Wednesday, February 10, 2010

Microsoft’s Product Logo

Microsoft provided official product logo download for us.

Check this out.

http://www.microsoft.com/Presspass/gallery/ms-logos.mspx?FINISH=YES

createdon vs overriddencreatedon

When we create a record in CRM, the created on field always points at the date the record is created. Of course we could go into the database and update the date by using a SQL script. But then again, “it's not supported".

And what we found from CRM SDK. createdon is a Read-only field and can’t be updated and created.

Platform required : No
Application requirement level : Read-only
Valid for create : No
Valid for retrieve : Yes
Valid for update : No

After googled it around, I found a something interesting…


In CRM 4.0, the CRM development team has silently introduced a new feature – overriddencreatedon field. While creating a record, we can set the attribute overriddencreatedon field. The value of this field will be used to set the record's created on attribute.

account agent = new account();
 
agent.new_agentname = "pq";
agent.overriddencreatedon = CreateCrmDateTime(new DateTime(2004, 10, 19));
 
services.Create(agent);

















A small feature makes big differences.

CRM 4.0 Get the FetchXML queries in Advanced Find

You can just open the Advanced find page and build the query as you like. Then run the query to see if it returns the data as you wish it should. Press F11 to get the address bar and enter this script and press enter.

javascript:alert(resultRender.FetchXml.value);

or

javascript:prompt("my query:", resultRender.FetchXml.value);

Friday, February 5, 2010

Reindex an entire database

The following query is to reindex an entire database.

EXEC [sp_MSforeachtable] @command1="DBCC DBREINDEX('?')"

If you want to receive progress messages while it is running, try this version

EXEC [sp_MSforeachtable] @command1="RAISERROR('DBCC DBREINDEX(''?'') ...',10,1)
WITH NOWAIT DBCC DBREINDEX('?')"

Click here for reference.

Wednesday, February 3, 2010

Display Report in IFrame

Recently I read a blog on displaying SSRS report in IFrame of CRM entities. Now, I'm going to share with the workaround..

For this example, we created a custom report that takes in the Account Id as a parameter and displays the report.

  1. To add report in report manager, go to report manager URL and upload the report file .*rdl.
  2. After that, to find the report URL, go to report server and right click on report's properties to copy the URL.
  3. Add a IFrame in Account entity and URL of the IFrame, enter ‘about:blank’.
  4. We will now add logic in the form OnLoad event that will create the report URL and append the Account Id for the report to use to display the report.
  5. Add the following codes in OnLoad.
    var guid = crmForm.ObjectId;
    
    var url = 'http://tbe/ReportServer?%2fTesting_AddReportIntoIFrame&rs:Command=Render&rs:Format=HTML4.0&rc:Toolbar=false&rc:Parameters=false&rc:Parameters=false&AccountId=' + guid;
    
    document.getElementById('IFRAME_Testing').src = url;
    
    
  6. Now save and close the form and publish the entity.
  7. Navigate to an account and you should see the new tab and report render in the IFrame.
Notes:
  • Since we want the report in an IFrame, we do not want the report viewer toolbar and parameters to show. Hence the ‘rc:Toolbar=false&rc:Parameters=false”. Since we want the report to render in HTML 4.0, we can specify the format to render the report in by specifying ‘rs:Format=HTML4.0’. 

Wednesday, January 27, 2010

Google Maps in CRM

One way to customize the Microsoft dynamics CRM 4.0 is to use IFrames from within the customization module in the application. This flexible way of extending the functionality of Dynamics CRM 4.0 open endless stream of enhancements that you can add to your CRM application passing dynamic values from /to CRM as parameters to control the IFrame application behaviour.

Blocks of JavaScript code below show how the Geocoding magic is called:
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Geocoding Simple</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
    var geocoder;
    var map;
    function initialize() {
        geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(-34.397, 150.644);
        var myOptions = {
            zoom: 15,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    }

    function setGoogleMapDomain(myDiv, domain) {
        var frames = myDiv.getElementsByTagName('iframe');
        if (frames.length > 0) {
            window.frames[frames[0].id].document.domain = domain;
        }
    }

    function codeAddress() {
        var xxx;
        if (document.URL.indexOf('?') == -1)
            xxx = "kuala lumpur, malaysia";
        else
            xxx = document.URL.substring(document.URL.indexOf('?') + 9, document.URL.length);
        xxx = xxx.replace(/%20/gi, ' ');
//        alert(xxx);
        var address = xxx;
        var image = 'new.gif';
        if (geocoder) {
            geocoder.geocode({ 'address': address }, function(results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location,
                        icon: image
                    });
                } else {
                    alert("Geocode was not successful for the following reason: " + status);
                }
            });
        }
    }
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize(); codeAddress();">
<div id="map_canvas" style="width:600px; height:400px;"></div>
</body>
</html> 

After that, just right click your .aspx file and view in browser.

Implement into CRM

  1. Create a IFrame in CRM page.
  2. Set the appropriate properties.

You should see Google Maps in CRM like this:




















For more information in using Google Maps API, click this.