Open Webresource with JS and Refresh form on Closing – Dynamics 365

  var serverUrl = Xrm.Page.context.getClientUrl(); 
 var addParams = "EntityName=" + EntityName + "&EntityId=" + EntityId;
var AddCommentsHTML = serverUrl + "/WebResources/new_CommentHTML?Data=" + encodeURIComponent(addParams);
 var win =, "ModalPopUp", "toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=0,width=600,height=350,left = 150,top=100");

    var timer = setInterval(function () {
        if (win.closed) {
            //Refresh Form after closing Pop-up
    }, 500);

Read Parameter passing through Data:
 var passedparams = ParseQueryString(GetGlobalContext().getQueryStringParameters()["Data"]);

         var EntityId = passedparams.EntityId;
          var  EntityName = passedparams.EntityName;

        function ParseQueryString(query) {
            var result = {};
            if (typeof query == "undefined" || query == null) {
                return result;
            var queryparts = query.split("&");
            for (var i = 0; i < queryparts.length; i++) {
                var params = queryparts[i].split("=");
                result[params[0]] = params.length > 1 ? params[1] : null;
            return result;

Issue while with relative URL using the WebResources folder


  • Mscrm is not defined Error occurred inside HTML Web Resource.
  • Icons are not displaying in Cases View


We have referred “ClientGlobalContext.js.aspx” in HTML web Resource as below:


HTML Web Resource having Mscrm. to return to the Previous window. But, its giving error for some of the Users only as “Mscrm is not defined.”

Same users are not able to see “Icons” in cases view.


I have drilled down into Issue. By pressing F12, I observed the Icons also referring “/WebResource/icon.png”. When I change to “../WebResource/icon.png” from Developers tools window [F12], it started working.

After doing a bit of research, I found the users who are facing Problem are existed in Multiple Instances in same server. One of the Instance they are not assigned with Security Roles. Hence, These issue came while accessing Cases and Custom Web Resource.


1. Update Users Default organization in MSCRM_CONFIG DB [We should do this by backend]

2. Assign Missing Roles in all Environments [My Case, This is a Test Environment that created as a cloned environment with existing. So added Roles to this Test Account and started working in Main Environment].


Part-12: Create Sample Load Test Plug-ins–Performance Test in VS 2017

Load Test Plug-ins can be developed to expand or modify the Load Test built in functionality. Load Test allows to add Plug-ins and these Plug-in executes at the time of Load Test run based on specified Events.

To create Load Test Plug-ins, must create a class that inherits the ILoadTestPlugin interface. This class must implement the Initialize method of this interface. Below are the to create Load Test Plug-ins and Add them to Load Tests.

Below sample sends an Email once Load test finishes.

a. Open the test project that contains your load test.

b. Add a new class file

c. Add a using statement for

using Microsoft.VisualStudio.TestTools.LoadTesting;

d. Have the class implement the ILoadTestPlugin interface.

public class NotifyOnLoadTestCompletion : ILoadTestPlugin

e. There is one method in the interface that you must implement:

public void Initialize (Load Test)

PFB for the complete Load Test Plug-in (Taken reference from Microsoft MSDN Article)

using System;

using Microsoft.VisualStudio.TestTools.LoadTesting;

using System.Net.Mail;

using System.Windows.Forms;

namespace SampleLoadTestPlugin


public class NotifyOnLoadTestCompletion : ILoadTestPlugin


LoadTest myLoadTest;

public void Initialize(LoadTest loadTest)


myLoadTest = loadTest;

myLoadTest.LoadTestFinished += new



void myLoadTest_LoadTestFinished(object sender, EventArgs e)




// place custom code here

MailAddress MyAddress = new MailAddress(“”);

MailMessage MyMail = new MailMessage(MyAddress, MyAddress);

MyMail.Subject = “Load Test Finished — Admin Email”;

MyMail.Body = myLoadTest..Name + ” has finished.”;

SmtpClient MySmtpClient = new SmtpClient(“localhost”);



catch (SmtpException ex)






Please refer below references for Load Test Plug-in samples and List of events those supported in Load Test Plug-ins.

XML File is opening Instead of Downloading on Ribbon Button Click–Dynamics 365 Java script

We have a requirement to download the XML file that placed inside Server on Ribbon Button click.

It is working as expected. We observed that XML file opening instead of downloading in some of the users systems.

1. Open IE – Settings Icon

2. Select Internet Options

3. Go to Security Tab – Click on “Custom Level”

4. You can find “Downloads” section. Select “Enabled” for File Download option – Click OK


This is very simple settings worked for us. Even its simple, It might useful for someone so sharing Smile

Part-11: Send Record ID Dynamically–Dynamics CRM Performance Test

As mentioned in Part-10, we need to capture Record ID for Update, Resolve or Cancel Scenarios. After capturing the Record ID we need to send this dynamically with Update, Resolve or Cancel Requests.

Refer below steps to set Dynamic Record ID:

1. Same recorded Web Performance Test find out the request that used for request [Ex: Update, Resolve or Cancel <<EntityName>>.I took here as Resolve Case].


2. Right click on “String Body” and select Properties (This is the request will send to server to resolve case)

3. Copy the String Body into Notepad.


4. Check for the GUID format (or) Get the Case GUID that created as part of web performance Test recording.[After successful Web Performance Test Run “Part-3” it creates a record in CRM]

5. Search the Case GUID within “String Body”

6. Replace it with Extraction Rule Name in below format – [Use same Name that given while extracting Record ID from Create Request – Part-10]



Part-10: Extract Record ID from InlineEditWebService.asmx–Dynamics 365 Performance Test

Update, Assign, resolve cases scenarios need to capture the created Case ID. Because, while recording the Resolve case scenario, web test hardcodes the Case ID that generated as part of recording. Hence, Load Test will throw an error if we execute the recorded web performance test as tool try to resolve the same case again.

Visual Studio performance Test provides an option to extract the created CaseID and stores into a Parameter. This parameter can be used in later step while resolving case.

Follow below steps to extract the Case ID from the create Request and use it in Resolve request.

Extract Case ID:

1. Record the Create and Assign Case scenario with Web Performance Test (Refer Part-3)

2. Open the recorded Web Performance Test

3. Look for the Service Request (InlineEditWebService.asmx). There would be many requests like this but based on the Request and Response find out the correct Request

4. Right click on the Request – Select “Add Extraction Rule”

5. Select “Extract Regular Expression” from left side navigation

6. Enter the Name

7. Enter below Regular Expression to extract Case ID (32 digits with 4 “- “)




Part-9: Error – The input is not a valid Base-64 string as it contains a non-base 64 character

We would receive below error while executing “InlineEditWebService.asmx” Request after setting CRMWRPCToken and CRMWRPCTokenTimeStamp values as per Part-7 and Part-8].


The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters



Extracted CRMWRPCToken [From Part-7] would have extra chars like “\”. This doesn’t accept by CRM because it corrupt the Base=64 format. so need to replace these values.


Refer below steps to overcome this issue.

1. Look for the Service Request (InlineEditWebService.asmx) – [Same Request we added CRMWRPCToken and CRMWRPCTokenTimeStamp at Part-8].

2. Right Click – Select “Add Request Plug-in”

3. Enter the values as per below screen


Part-8: Pass CRMWRPCToken and CRMWRPCTokenTimeStamp for CRM Requests

Recorded Web Performance Test would have request like “InlineEditWebService.asmx”. This is the Request sending to Server for Create/Update Operations. We need to Pass CRMWRPCToken and CRMWRPCTokenTimeStamp to this request over the Header. [Refer Part-7 to extract these values from Data.aspx Request.]

Below are the steps to send over Header:

CRMWRPCToken Header

1. Look for the Request (InlineEditWebService.asmx)

2. Expand to Headers – Right click – “Add Header”

3. Double click on created value and Enter below values:

Name: CRMWRPCToken

Value: CRMWRPCToken

CRMWRPCTokenTimeStamp Header

1. Look for the Request (InlineEditWebService.asmx)

2. Expand to Headers – Right click – “Add Header”

3. Double click on created value and Enter below values:

Name: CRMWRPCTokenTimeStamp

Value: CRMWRPCTokenTimeStamp

Part-7: Extract and Capture CRMWRPCToken from CRM Requests

Web Performance Test Recorded scenario generates “Data.aspx” on Clicking “+New” button or onloading Existing Record. This Requests get a new CRMWRPCToken for each request. We need to Extract this Token from the Request and send back with Create/Update request with Header.

Please find below steps to Extract CRMWRPCToken from “Data.aspx” request:

1. Record the Create request (Ex: Create Account) by using Web Performance Test (Please refer Part-3 for the same)

2. Go to recoded Webtest

3. Find the request like “…/form/data.aspx”. This is the request execute when we initiate the Create request (Clicking +NEW). CRM sends WRPC_TOKEN as part of this response.

CRMWRPCToken Extraction Rule:

1. Right click on Data.aspx and select “Add Extraction Rule”


2. Right click on created Rule – Select Properties

3. Provide the Properties as below:




CRMWRPCTokenTimeStamp Extraction Rule:

1. Right click on Data.aspx and select “Add Extraction Rule”

2. Right click on created Rule – Select Properties

3. Provide the Properties as below:




Part-6: Understanding WRPC_TOKEN and Timestamp in Dynamics CRM Operations

Web Performance Test for Searching scenarios works without error. But, when it comes to Create and Update request we will get WRPC_TOKEN related errors. Generally, when we initiate the Create request (Clicking on +New) CRM send a token to users and it send back to server with Create request Header on clicking save. WRPC_TOKEN and Timestamp are generated by CRM server for each Request separately.

Web Performance Recording time we will make a Create Request and CRM server generates WRPC_TOKEN and it will be sent to CRM server on clicking Save. This recording hardcodes the TOKEN. But, when we re-run the same Web Performance Test again then same TOKEN will be sent to CRM server, so we will receive below Error.