Monthly Archives: October 2012

Minor things that make a difference – naming your report files in Dynamics CRM 2011

Did you ever want to build a report in Dynamics CRM and download it in PDF format without having to manually rename the file? This is one of those things that makes a difference from the end user perspective since it streamlines the process – there is no need, anymore, to go back to the underlying record and copy-paste information from some of the fields to the file name.

Unfortunately, even though it seems reasonable, this feature is not supported out of the box. Moreover, Dynamics CRM uses SSRS for reporting, and, to the best of my knowledge, SSRS does not support this feature either. This is not to mention that we have limited control over SSRS functionality when working with Dynamics CRM in general and with the online version of Dynamics CRM in particular.

We can make it work, though, and you will find step-by-step instructions below. Please keep in mind that this solution uses some of the undocumented java script SSRS-related objects which may or may not exist in the newer versions of Dynamics CRM. As of now it works, though, and, I believe, all those undocumented features (there are really just one or two) will be available in the future.

So, here is what we have out of the box:

image

 

It is the last step that we want to eliminate:

 

image

We want to be able to name the file automatically as part of the “Export to PDF” step.

Here is how we are going to do it:

  1. We will do it using “salesorder” entity as an example, but it is easy to do the same for other entities as well.
  2. We will create a java script that will be loaded as a web resource to the order form.
  3. In that java script, we will define a single function that will be called in form “onload”.
  4. That function will re-define window.open so that we can run additional code whenever user decides to build a report.
  5. Our additional code will use java script setTimeout in order to wait until the report is loaded, and, then, modify report file name.

We will be using undocumented features of Dynamics CRM only once: in order to modify the file name, we will have to access java script instance of the reporting component. I believe this part of Dynamics CRM functionality is not really documented, but one can always use Internet Explorer developer tools (F12) to do some research.

Let’s take a look at the details:

  • Create a new web resource (jscript)
  • Give it a name (let’s use “new_reporting”)
  • Using web resource “text editor” button, add the following java script:

function setHandlers()
{
var newFileName = Xrm.Page.getAttribute(“ordernumber”).getValue();//Change attribute name for other entities
window.open = function (open) {
return function (url, name, features) {
var timeout = 2000;
var newWindow = null;
if(features != null) newWindow  = open(url, name, features);
else if(name != null) newWindow  = open(url, name);
else newWindow  = open(url);
function timeoutFunc()
{
var rv = null;
var r = null;
try
{
rv = newWindow.frames[ “resultFrame” ].$find(“reportViewer”);
r =rv._getInternalViewer();
}
catch(err)
{
setTimeout(timeoutFunc, timeout);
return;
}
if(r == null)
{
setTimeout(timeoutFunc, timeout);
return;
}
else
{
var url = r.ExportUrlBase;
var i = url.indexOf(“FileName=”);
var j = url.indexOf(“&”, i+1);
var oldFileName = url.substring(i+9, j);
r.ExportUrlBase = url.substring(0,i) + “FileName=”+ newFileName + oldFileName + url.substring(j);//Use this line to assign new file name
}
};
if(url.indexOf(“viewer.aspx”) > 0)
{
setTimeout(timeoutFunc, timeout);
}
return newWindow;
};
}(window.open);
}

This function does the following:

  • It overrides window.open with a new function
  • Whenever another java script makes a call to window.open, our overridden version will be called instead
  • First, we will forward that request to the original window.open. After that, we will verify if requested url contains “viewer.aspx” substring. If it does not contain such a substring, we don’t need to do anything.
  • If it does contain the substring, we will use setTimeout using internal “timeoutFunc” as a parameter
  • The purpose of the internal “timeoutFunc” function is simple:
  • It will verify if the report is loaded. If not, it will call another setTimeout, and it will keep doing it until the report is finally loaded (yes, there could be potential problem here)
  • If the report has been loaded, finally, it will update “ExportUrlBase “ property of the reporting control

And that’s, pretty much, it.

What’s left is:

  • Save this web resource and publish it
  • Add this web resource to the order form
  • Add “onload” event and specify setHandlers java script function for that event
  • Save order form and publish it

Finally, verify the results:

image

Hope this helps.

Different faces of Dynamics CRM

I have to admit I’ve been in the trenches, and that’s been happening for quite a long time since I’ve managed to miss this announcement:

“What did CWR Mobility and Microsoft announce?

CWR Mobility and Microsoft announced on February 6, 2012 that the Microsoft Dynamics® CRM Q2 2012 service update will deliver the capability for customers to access the complete functionality of Microsoft Dynamics CRM on any device with a new cloud-based, cross-platform, native mobile client service called Microsoft Dynamics CRM Mobile for Windows® Phone 7, iPad®, iPhone®, Android™ and BlackBerry®  mobile devices.”

See details here: http://www.cwrmobility.com/mobile-crm-faq

That did not happen in summer, though. However, Microsoft has recently published it’s December release preview guide which sticks to the point that Dynamics is really going to be supported on tablets and browsers-other-than-IE, so it may still happen.. or may not:

http://crmpublish.blob.core.windows.net/docs/Release_Preview_Guide_December_2012_FINAL.pdf 

That, combined with the fact that I’ve spent a couple of days this week evaluating Resco.NET and CWR for the client, multiplied by the fact that most of the users would love to customize Dynamics UI a little(or far) beyond what’s available out of the box, kicked of a different thought process. It would be great if someone came up with a powerful UI framework for CRM applications. Such systems as Dynamics and Salesforce have very efficient backends. However, when it comes to the UI, you suddenly feel like your very basic freedoms have been cut off. After all, I do want to be able to see a different logo when I log in. I do want to play with filters, forms, views – that’s what most of the users will be working with. But I can’t.

And I don’t think I’m alone here, though some people may be taking it to the extreme (or are they?):

http://social.microsoft.com/Forums/en/crmdevelopment/thread/56355a6e-0333-4b0a-a0ba-6a05709a6436

What CWR example really demonstrates, though, is that it’s doable, and Resco.NET gives yet another example (On a side note, I’m not sure if I like CWR more).

So, would it be possible? Do you happen to know of any existing UI frameworks that can be easily connected with Dynamics? Should we kick off a codeplex project to finally give different faces to Dynamics CRM?

PS. With that said, December release preview does mention browsers support, and it does not mention native clients. What’s interesting is that it specifically mentions very recent browser versions for non IE browsers(Chrome v22, for instance), which might be a hint of HTML 5 client being developed for Dynamics. December release preview also does not mention support for Android tablets, and CWR does have that support.. So, after all, maybe the deal did not work out and we are going to see something completely new from Microsoft.

Dynamics CRM: Scribe vs SSIS

I used to think that Scribe is almost the only choice when it comes to ETL tools for Dynamics CRM. It is convenient, it does the job, it is the first tool that comes to mind.. However, I recently tried to create an SSIS package using SSIS adapter for Dynamics CRM from Kingsway Soft, and I’m not so sure now.

SSIS adapter is convenient, it does the job, and, now, it’s the first tool that comes to mind.

Why?

Because it is different now.. There are SSIS adapters for Dynamics CRM from such companies as kingswaysoft.com, CozyRoc.com, and, probably, from some others. Those adapters make it much easier to create SSIS packages for Dynamics CRM.

I tried to look up a comparison of Scribe and SSIS (for Dynamics CRM), and the following link came up:

http://cowia.com/ssis-vs-scribe/

Let’s face it – it’s not the best link. But it pretty much reflects my own subconscious ideas I had until recently, so I’ll still use it. The thing is, however, I believe that post is quite outdated now. Here is how it should look:

  • Scribe has CRM adapter. SSIS has CRM adapters
  • SSIS is free tool from Microsoft. Scribe needs a license(and an expensive one)
  • SSIS has super performance. And you don’t need to spend a lot of time coding (because there is an adapter now)
  • Scribe has great performance – much less time needed to get your solution ready. This one is quite controversial. It really did not take that much time to create an SSIS package.

And there is one item that I would still give to Scribe: automation, notifications, easy to install and redeploy. I’m not sure that justifies the cost of licenses, though. Since Scribe licensing depends on the number of CRM users, and none of the SSIS adapters I’ve seen so far take number of users into account, the difference can be more than significant (2k vs 20K).