Friday 20 January 2012

CRM 2011 Customization - Decrypt default Javascript files in CRM Server

 So it's this, the first blog !!!

Two weeks ago, during the time writing a Javascript to customize a CRM button, I found out the way how to decrypt the default Javascript files in CRM server which are might be helpful for you to refer and understand how CRM functions were built.

What I wanted is tracing what they did when building the Campaign Activity entity. Then I exported the default solution and looked what they did with the entity. Opening the customization file, you can see in the picture, there are 3 javascript files applied for it:



As you see, the "CamPaignActivity_main_system_library" was located somewhere in the server and defined in Javascript by "$webresource". It took me several hours to find where actually the file was. Then, the tip is very simple, CRM itself has a database which store all things in the system inside. And in the database, there is an view named "WebResource" where you could look for any webresource belongs to your CRM system. So what you need to do is: opening SQL Server --> CRM Database --> put the query to find WebResource View.

Look at the following pic to refer:


So now I find out the content of the javascript file ! But this content is encrypted. Actually, they just converted them into a different kind of string. Then you need to make some code to decrypt in order to take the real javascript content. The C# code below:

 protected void Button1_Click(object sender, EventArgs e)
        {       
            byte[] binaryData = System.Convert.FromBase64String("//here is your javascript encripted content//");
            string x = System.Text.Encoding.ASCII.GetString(binaryData);              
            Response.Write(x);      

        }

So now, you had the javascript file with decrypted content. I hope it's helpful ;)


No comments:

Post a Comment