My eXperience

Microsoft CRM and Android

Find where deprecated getServerUrl is being used CRM 2015 JavaScript files.

This article applies to CRM OnPremise.

After upgrading from CRM 2013 to CRM 2015, I was promptly greeted by the error message shown below.

getServerUrl

The solution is to replace getServerUrl with getClientUrl in the JavaScript files.

The real question is “How do you know which JavaScript files to edit”.
My solution was to create a console application that would search CRM for JavaScript files containing getServerUrl.

capture 10

  • Create a new Console Application project in Visual studio and call it CRMUpgrade as shown above.

Capture 11

  • Right click on your project in solution explorer and select Add New item.

In the Add New Item screen,  select ADO.NET Entity Data Model and name it CRMUpgradeModel. Click the add button.

Capture  12

In the next screen select EF Designer from database and click next.

Capture 13

enter your credentials to connect to your CRM database. and click OK.

Capture 14

click next in the next screen.

Capture 15

Expand Views and dbo then search for WebResource.

Capture 16

 

Capture 17

Click Finish. you are now ready to write some code.

Open the Program.cs file and add the following methods

  1.    private static void StartLoop()
  2.     {
  3.         Console.WriteLine("Press 1 to search for javascript files containing specific text.");
  4.         Console.WriteLine("Press any other key to Exit!!!");
  5.  
  6.         ConsoleKeyInfo key = Console.ReadKey();
  7.         string action = key.Key.ToString();
  8.  
  9.         if (action == "NumPad1" || action == "D1")
  10.         {
  11.             Console.WriteLine();
  12.             Console.WriteLine("Enter text to search for in javascript and Html files and press enter");
  13.             string searchString = Console.ReadLine();
  14.             PerformSearch(searchString);
  15.  
  16.         }
  17.  
  18.     }
  19.  
  20.     private static void PerformSearch(string searchString)
  21.     {
  22.         //Crm_MSCRMEntities =
  23.         Crm_MSCRMEntities ctx = new Crm_MSCRMEntities();
  24.         string decryptedConted = string.Empty;
  25.         //string searchString = "OrganizationData.svc";
  26.         Console.WriteLine(String.Format("Searching for {0}", searchString.ToLower()));
  27.  
  28.         foreach (var item in ctx.WebResources)
  29.         {
  30.             decryptedConted = GetContent(item.Content);
  31.             if (decryptedConted.ToLower().Contains(searchString.ToLower()))
  32.             {
  33.                 Console.WriteLine(String.Format("Resource {0} contains {1}", item.Name, searchString.ToLower()));
  34.  
  35.             }
  36.         }
  37.  
  38.         Console.WriteLine("Completed");
  39.         Console.WriteLine();
  40.         StartLoop();
  41.     }
  42.  
  43.     public static string GetContent(string encryptedContent)
  44.     {
  45.         if (encryptedContent == null)
  46.         {
  47.             return string.Empty;
  48.         }
  49.         byte[] binaryData = System.Convert.FromBase64String(encryptedContent);
  50.         string unencryptedContent = System.Text.Encoding.ASCII.GetString(binaryData);
  51.         return unencryptedContent;
  52.     }
  53. }

Next step is to call StartLoop from the Main method.

Capture 19

Press F5 to run your application and search CRM.

Capture 20

Comments (1) -

  • Bongani

    3/18/2015 7:14:49 AM |

    useful article

Comments are closed